Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Quirky regex bug

by japhy (Canon)
on Jan 07, 2002 at 02:41 UTC ( #136725=note: print w/ replies, xml ) Need Help??

in reply to Re: Quirky regex bug
in thread Quirky regex bug

Yes. From the source (regcomp.c:1851):

else if (!sawopen && (OP(first) == STAR && PL_regkind[(U8)OP(NEXTOPER(first))] == REG_ANY) && !(r->reganch & ROPT_ANCH) ) { /* turn .* into ^.* with an implied $*=1 */ /* ... */ }
So you can see it is only for regexes starting with .* -- if you look a few lines up, you see:
/* Skip introductions and multiplicators >= 1. */ while ((OP(first) == OPEN && (sawopen = 1)) || /* ... */ ) { /* ... */ }
So it's ignoring the fact that the .* might actually be inside parens.

My patch consisted of the text "!sawparen &&" in the code block up top. Big patch, I know.

Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Comment on Re: Re: Quirky regex bug
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://136725]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-10-13 17:44 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (311 votes), past polls