Let's say I have a multiline string like this:
STARTFRUIT banana ENDFRUIT STARTFRUIT avocado ENDFRUIT STARTVEGGIE rhubarb ENDVEGGIE STARTFRUIT lime ENDFRUIT
I want to look for all the fruits, without vegetables. I try this:
MatchCollection myMatches = Regex.Matches(tbBlob.Text, "STARTFRUIT.*ENDFRUIT", RegexOptions.Singleline); foreach (var myMatch in myMatches) { Forms.MessageBox.Show(String.Format("Match: {0}", myMatch), "Match", Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Information); }
The problem is that instead of returning an array of three matches to me, it gives me a big match, including the first STARTFRUIT and the beginning and last ENDFRUIT at the end. Is there a way to "minimize" a coincidence search? I do not see any help in RegexOptions .
c # regex
Jccyc
source share