c#正则表达式匹配字符串,获取组的值

来源:互联网 发布:python二分法解方程 编辑:程序博客网 时间:2024/05/18 02:42

string input="828374823[938929293]"; 

Regex regex=newRegex(@"(.+)?\[(.+)?\]",RegexOptions.IgnoreCase);
if (regex.IsMatch(input))
{
   MatchCollection matches = regex.Matches(input);
    foreach(Match match in matches)

    {
    txtBox1.Text= match.Groups[1].Value;
    txtBox2.Text=match.Groups[2].Value;    

    }
      

0 0
原创粉丝点击