我有這樣的片段執行正則表達式搜索:正則表達式:反轉匹配順序
public IEnumerable<MyMatch> GetMyMatches()
{
Match m = myRegex.Match(Text, offset);
if (m != null && m.Success && m.Value != null && m.Value.Length > 0)
{
offset = m.Index+m.Length;
yield return new MyMatch() { Match=m, SomeFurtherInformation=... };
} else
yield break;
}
正如你所看到的,我走所有occourences在我的文字。
但如何反轉搜索方向?
感謝您的幫助
注意:m!= null始終爲真,m.Value!= null也是如此,除非有例外(比如偏移量太大)但是沒有m :-)如果沒有匹配,則Value = =「」。 – xanatos