Link to home
Create AccountLog in
Avatar of 97WideGlide
97WideGlide

asked on

c# regex Match variable number of strings

Hi,
The following regex code will match two strings which fall in between ">" and "<":
--------
string rawReview = "aaaaaaaa>string1<bbbbbbb>string2<cccccccc";
           
match = Regex.Match(rawReview, @">([^<]*).*?>([^<]*)");
if (match.Success)
{
    Console.Write("Match found  {0} {1}\n", match.Groups[1], match.Groups[2]);
}
--------
Match found string1 string2

I would like to extend this example to be able to match an arbitrary number of strings which fall between the bracket chars.  Is this possible?  

Thank you very much for reading and considering my question.
ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of 97WideGlide
97WideGlide

ASKER

Simple when you know what you're doing.  I solved it last night after two hours using a MatchCollection which clearly wasn't necessary.  Your solution taught me a bit about regular expressions.

Thank you very much.