0

I've written a regex...

    internal static readonly Regex _parseSelector = new Regex(@"
        (?<tag>"+_validName+@")?
        (?:\.(?<class>"+_validName+ @"))*
        (?:\#(?<id>"+_validName+ @"))*
        (?<attr>\[
        \])*
        (?:\:(?<pseudo>.+?))*
    ", RegexOptions.IgnorePatternWhitespace);

Now I want to get all the "class" bits...

var m = _parseSelector.Match("tag.class1.class2#id[]:pseudo");

How do to retrieve the list class1, class2 from the match object?

mpen
  • 272,448
  • 266
  • 850
  • 1,236

2 Answers2

2
foreach (var c in m.Groups["class"].Captures)
{
    Console.WriteLine(c);
}

Hurray for guessing.

Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
mpen
  • 272,448
  • 266
  • 850
  • 1,236
1
m.Groups["class"]
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Yeah.. see, that part I knew, but `.Value` only returns the last match it seems. It's `.Captures` that I was looking for. – mpen Oct 03 '10 at 19:28