On Tue, 6 Nov 2001, David Alan Black wrote:
> On Tue, 6 Nov 2001, Mathieu Bouchard wrote:
> > No, I deleted all relevant code because it didn't work properly. To make
> > any use of the Regexp class worthwhile to me, Regexps should support
> > embedded Ruby expressions, access to info like which branch of an
> > alternative was chosen, failure handling, and continuations based on the
> > availability of data.
> Well, one out of four ain't bad :-)
>   irb 10> a = "abc"
>    ==>"abc"
>   irb 11> /#{"abcd".chop}/.match(a)[0]
>    ==>"abc"

That's zero of four. You see, in another post today I've demonstrated
heavy use of regexp-interpolation, but that's still not what I mean by
embedded Ruby expressions. I mean executing code each time a match is
found; in particular, binding a block to each pair of (collecting)
parentheses. That way I wouldn't get only the last match; I could get all
the matches instead, and perform some action as they are found.

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju