http://qs321.pair.com?node_id=183870


in reply to Regular Expressions: Call for Examples

Can I throw a problem at you that I never took the time to think out and that may add some salt to your book? In perl5, it is impossible to get at capture in an embedded regular expression:

my $qr = qr|whatever(somecapture_re)whatever|; my ($captured) = m/$qr/; # does not work

A few week ago, I looked at your draft (forgot the URL). It looks promising. My problem is: find an API to stash away that information and get it back. Probably, it will not very pretty but there no way to "modularize" regexen in perl5. I mean by that, to build interesting regexen from simpler ones.

I once looked at your draft (forgot the URL), it seemed pretty interesting.

-- stefp -- check out TeXmacs wiki

Replies are listed 'Best First'.
Re: Re: Regular Expressions: Call for Examples
by jryan (Vicar) on Jul 21, 2002 at 21:54 UTC
    my $string = "whateversomecapture_rewhatever"; my $qr = qr|whatever(somecapture_re)whatever|; my ($captured) = $string =~ m/$qr/; print $captured, " ", $1;
    prints:
    somecapture_re somecapture_re