Hi --

On Fri, 15 Aug 2003, Minero Aoki wrote:

>   TANAKA Akira suggested a new function, to capture all matchings for
>   the one expression.  e.g.
>
>     m = /(?@<name>\/\w+)+/.match("/usr/local/bin/ruby")
>     p m['name']   #=> ["/usr", "/local", "/bin", "/ruby"]

Question:

Would this also be captured in the numerically indexed submatches?
(So, in the above, m[1] would still be "/ruby".)

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

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav