On 10/2/10, Ammar Ali <ammarabuali / gmail.com> wrote:
> Fellow Rubyists,
>
> I put together a couple of Regexp extension experiments (aka hacks)
> that I would like to run by those how might be interested and have the
> time. The code is at:
>
>   http://github.com/ammar/meta_re
>
> There's a small README that explains what this does with some
> examples. There are also a few tests, but nothing I would call
> exhaustive. They mainly test that the plumbing, well, plumbs.
>
> I hope someone finds this useful, or at the very least amusing. I also
> hope to hear from others if they think this would be useful as a gem.

Wow, that's pretty cool, actually. I like it. A couple of criticism
(meant as constructive):

I'm a little concerned about what will happen with this regexp:
/(?:foo){1,10000}/. Currently, Regexp handles this just fine, but with
your lib I fear there might be a performance problem.

Your Regexp parser looks to me to be a little naive. I gave it only
the briefest of scannings, but it looks like you're not handling
special characters escaped by [ and ], nor some of the other types of
ways of using backslashes, like \C-x, for example. I'm not entirely
clear what happens if there are two or more backslashes in a row. (A
character is only escaped by backslashes if preceded by an odd number
of them.)

I wrote a more complete (at least I hope so) regexp parser (but also
specialized for my purposes) as part of my lib sequence. See the
group_anchors method in this file:
http://github.com/coatl/sequence/blob/master/lib/sequence/stringlike.rb

It would be nice to have a Regexp parser as a standalone library, actually.