What about:
re = /((?@<paths>(\/\w+)+\/)(?@<filenames>\w+),?)+/
m = re.match("/usr/local/bin/ruby,/bin/bash,/sbin/reboot")
m['paths'] # => ["/usr/local/bin/", "/bin/", "/sbin/"]
m['filenames'] # => ["ruby", "bash", "reboot"]
My regexps may be off (didn't test :)), but you get the idea.
Wouldn't that require multiple regexps with scan?
- Dan (posting from a news server because the blackout killed his e-mail
:( )
dblack / superlink.net wrote:
>
> Comment:
>
> The first thing I thought was that this looks like an alternative way
> (or very close) of doing this:
>
> name = "/usr/local/bin/ruby".scan(/\/\w+/)
>
> and I still kind of think that :-) Is there a big advantage to making
> this kind of result-naming a regex extension, rather than just using
> regexes to generate the results and saving/naming the results
> separately (the way #scan does)?
>
> (I guess that comment was really also a question :-)
>
>
> David
>