in reply to RE: Probably silly regex question / not so silly regex question
in thread Probably silly regex question / not so silly regex question
> m/([^c]*c)/ will only gobble up until it finds a c, because the c won't > satisfy ^c; then it matches the c. No backtracking. The non-greedy version (m/(.*?c)/) will > match zero characters, and then look for a c; then match 1 character, and then look > for a c; then match match 2 characters, and look for a c; and so on.
This seems to indicate that m/(.*?c)/ and m/([^c]*c)/ will always match the same strings, but the first will be far fatster (in _all_ cases, that I can see at least). So why isn't the first optimized into the second?
I'm probably not seeing somthing here.
Thanks, James Mastros, Just Another Perl Initate
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: Probably silly regex question / not so silly regex question
by jlistf (Monk) on Aug 01, 2000 at 23:34 UTC | |
|
RE: RE: RE: Probably silly regex question / not so silly regex question
by Anonymous Monk on Aug 02, 2000 at 01:13 UTC |