我的测试字符串
“示例字符串 123 与示例字符串在海上有小词”
得到一个正则表达式:
var regex = new Regex(@"\b(?<tag>small|with)\b(?<param>.*)");
将结果分成两组:
G0=with, G1= 海面上有小字的示例字符串
G1 不好,我想看的是
G0=with, G1= 示例字符串 123
基本上我试图返回第一个匹配和第一个匹配之前的字符串。但是我在第一场比赛后得到了字符串
有人在我的 reg ex 中看到错误吗?#
Reply to your Question: Regex, get the rest of the unmatched string
Simple
string toSearchString = "your string here";
Match match = new Regex("*some pattern here*").Match(toSearchString );
string unmatchedString = toSearchString.Replace(match.Value,"");
So now you have the Unmatched String. you can have coffee!!
Note: 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.