Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#RegEx,第一场比赛_C#_Regex - Fatal编程技术网

C#RegEx,第一场比赛

C#RegEx,第一场比赛,c#,regex,C#,Regex,我有下一个字符串: String a = "someThing({Some text}); OtherStuff({Other text});"; 我需要在'someThing({…}')中的'{'和'}'中包含文本 我写道: var data = Regex.Match(a, @"(?<=someThing\(\{).*?(?=\}\)\;)", RegexOptions.Singleline).Groups[0].Value; var data=Regex.Match(a,@)(?

我有下一个字符串:

String a = "someThing({Some text}); OtherStuff({Other text});";
我需要在'someThing({…}')中的'{'和'}'中包含文本

我写道:

var data = Regex.Match(a, @"(?<=someThing\(\{).*?(?=\}\)\;)", RegexOptions.Singleline).Groups[0].Value;

var data=Regex.Match(a,@)(?下面的正则表达式将匹配零个或多个字符,但不匹配
}
}
中的字符,这些字符在
某物({


(?可能是因为它没有捕获
{
}
,可能是因为它没有检查关闭
。您的正则表达式运行良好:@casimirithippolyte他的预期输出是
{Some text}
(?<=someThing\({)[^{}]*
(?<=someThing\(){[^{}]*}
(?<=someThing\()({[^{}}]*})