in reply to (bbfu)(regex engine bug)Re: Re: RE prollem: \G, \\? and disappearing data
in thread RE prollem: \G, \\? and disappearing data

I tried for a while, but I couldn't coax Perl into playing nice with this one :)

It looks like Perl 5.005_03 simply ignores the \G anchor when a '?' modifier is present. It also ignores \G if there's a {0,1} modifier, but oddly enough, not in the cases of '*' or '{0,2}'. Though not quite accurate, perhaps one of these is a suitable substitute.

Another option is to expand the '?' modifier into its two possibilities like so:

m/\G(\\\$\w+|\$\w+)/gc
You can also dispense with the \G modifier altogether, and just slurp away the lexed tokens, using s/TOKEN// for matching, though this method is somewhat less efficient.
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
(bbfu)(MeowChow's workarounds)Re: Re: (RE bug)Re: Re: RE prollem: \G, \\? and disappearing data
by bbfu (Curate) on Feb 12, 2001 at 15:41 UTC

    Thanks for the further info. I ended up going with a similar case to your second suggestion (m/\G(\\\$\w+|\$\w+)/gc, though I didn't repeat the \w+ since there was other stuff in the regex after that) and it seems to be working fine.

    The s/// solution seems like it'd be quite expensive, requiring many, many memcopy's. As I'm using this tokenizer fairly heavily, I don't think that's really a good idea. Though, of course, maybe Perl's smarter than I'm giving it credit for. ;-)

    Hopefully pretty soon I'll be able to post the code I'm working on here for some peer review, as well as a link to a "showcase" page. It's getting pretty close to finished and I really think it's pretty cool. I'm looking forward to getting everyone's opinion on my code and the ideas behind it. I've really appreciated your help here, MeowChow, and I hope that you'll give it a look when I finally get it all posted. =)

    For now, I think I should really go to bed. It's 6am here and I have to get up in 6.5 hours to get ready for work (so that I can go in and work on this project some more! :-). Have a good night/day/whatever, everyone and thanks again!

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.