views:

69

answers:

1

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?

+1  A: 

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

Alan Moore
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
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
I've just looked at the Perl 6 regex docs. Wow, that *is* quite a change from Perl 5...
Tim Pietzcker