Can someone help me with expression needed to extract the entire string
>
FOO*1*DATA*DATA*ID~
1. This string pattern is embedded in a super long string..
TIA
This is my unsuccessful attempt
Regex re = new Regex("[F][O][O][*][0-9][*][~]");
MatchCollection m = re.Matches(content);
ArrayList al=new ArrayList();
foreach (Match m in m)
{
al.Add(m.Value);
}
Your regex matches a string FOO*1*~ (where "1" could be any number from
0-9). It doesn't match the string you give in your example, because of
the "DATA*DATA*ID" part.
If the string you are after starts with "FOO*1*" (but any number
instead of the 1) and ends with "~", you could use:
FOO\*[0-9]\*[^~]*~
the "[^~]*" part matches any string not containing a ~
(note: instead of "[F][O][O]" you can simply use "FOO")
Hans Kesting