我的测试字符串
“示例字符串123,其示例字符串在海上有小字”
得到一个正则表达式:
var regex = new Regex(@"\b(?<tag>small|with)\b(?<param>.*)");
将reuslt分成两组:
G0 = with,G1 =在海上有小字的示例字符串
G1不好,我希望看到的是
G0 = with,G1 =示例字符串123
基本上我试图在第一场比赛之前返回第一场比赛和字符串。但是我在第一场比赛后得到了这个字符串
有没有人在我的注册表中看到错误?#
答案 0 :(得分:3)
回复您的问题:Regex, get the rest of the unmatched string
<强>简单强>
string toSearchString = "your string here";
Match match = new Regex("*some pattern here*").Match(toSearchString );
string unmatchedString = toSearchString.Replace(match.Value,"");
所以现在你有了不匹配的字符串。你可以喝咖啡!!
注意:This answer is not relevant to the problem posted here but is relevant to the Question, This answer is for people who land up in this page seeking for fetching unmatched string
。
答案 1 :(得分:2)