6

As I just learned from this question, .NET regexes can access individual matches within a repeated capturing group.

I. e., if I apply a regex like \b(\w+\s*)+ to a string of words, only the last word will be stored in \1 or Match.Groups(1).Value, but using Match.Groups(1).Captures I get access to all the individual matches the regex iterated over.

Are there other regex flavors that support this besides .NET?

Community
  • 1
  • 1
Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561

1 Answers1

4

As far as I know, only .NET and Perl 6 offer that capability.

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
  • Thanks for Perl 6. Looks like the JGSoft engine is in for a little overhaul. Captures seem to me like a useful feature. I'm still on the fence whether recursive/balanced regexes are a Good Thing or whether they make regular expressions completely unmaintainable. – Tim Pietzcker Apr 16 '10 at 12:30
  • I tend to think that if you need recursion *or* intermediate captures, you shouldn't be using regexes at all. At least, not Perl 5 era regexes; Perl 6 includes major changes to regex syntax, making it easier to use advanced features like those and still be able to read what you've written. – Alan Moore Apr 16 '10 at 13:04
  • I've just looked at the Perl 6 regex docs. Wow, that *is* quite a change from Perl 5... – Tim Pietzcker Apr 16 '10 at 14:00