C# 下划线转驼峰
程序员文章站
2022-03-11 17:37:59
...
/// <summary>
/// 转换
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
string tb1 = textBox1.Text;
Match mt = Regex.Match(tb1, @"_(\w*)*");
while (mt.Success)
{
var item = mt.Value;
while (item.IndexOf('_') >= 0)
{
string newUpper = item.Substring(item.IndexOf('_'), 2);
item = item.Replace(newUpper, newUpper.Trim('_').ToUpper());
tb1 = tb1.Replace(newUpper, newUpper.Trim('_').ToUpper());
}
mt = mt.NextMatch();
}
textBox2.Text = tb1;
}
上一篇: 板栗南瓜怎么蒸?有什么好方法?
下一篇: 做好软文营销 这几点要求是必须的