求 正则表达式??
字符串内容为 setuser( "张三 ",19, "一年级 ")
怎样用正则表达式把 张三 19 一年级 提取出来?
------解决方案--------------------try
string yourStr = ..............;
Match m = Regex.Match(yourStr, @ "setuser\( " "(? <name> [^ " "]*) " ",(? <age> \d+), " "(? <grade> [^ " "]*) " "\) ", RegexOptions.IgnoreCase);
if (m.Success)
{
richTextBox2.Text += m.Groups[ "name "].Value + "\n ";
richTextBox2.Text += m.Groups[ "age "].Value + "\n ";
richTextBox2.Text += m.Groups[ "grade "].Value + "\n ";
}
PS:楼主例子中的“)”为全角吧,是因为手动输入的问题,还是说源字符串就是这样