I am tring to scan a html string for all content within cretain tags. In the
simplifed example below, I would like to scan the source text for all
occurrences of text that start with "A" and end in "c" without any
overlapping. In the following example, the regular expression finds only one
result that inludes the first "A" to the last "c". This is not what I want.
I want every non overlapping occurrance of "A" and "c". The result set
should be
Abc, Abc, Abxc, Abxc
NOT
AbcbbAbc something elseAbxcXYZAbxc
as it is now
Does anyone know How this can be done
Thanks
Earl
private void ParseTest()
{
ListBox2.Items.Clear();
string SourceString = "XYZAbcbbAbc something elseAbxcXYZAbxcAb";
Regex r = new Regex("A.+c");
MatchCollection mc = r.Matches(SourceString);
foreach(Match m in mc)
{
ListBox2.Items.Add(m.ToString());
}
}
Outputs only one result
==> AbcbbAbc something elseAbxcXYZAbxc