New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex bug: Getting two consecutive global matches to match with zero length #5773
Comments
From luisivan.tubert-brohman@yale.eduThis is a bug report for perl from luisivan.tubert-brohman@yale.edu, Regex bug: Getting two consecutive global matches to match with zero length Global matches can match zero characters, leaving "pos" unchanged. I have the following test program: $s = 'abcde'; which gives the following output, as expected: a?: Matched 'a' Using $s = 'bcde' gives the expected result again: a?: Matched '' Same for $s = 'acde': a?: Matched 'a' But when $s = 'cde' doesn't do what I expect: a?: Matched '' The same kind of problem happens with $s = 'ade': a?: Matched 'a' Running the $s = 'cde' case with "use re 'debug'" gives the following: The fist regular expression matches zero characters as expected. The second The same thing happens with perl 5.0, 5.6, and 5.8. Site configuration information for perl 5.00503: Configured by root at Mon Aug 30 23:08:56 EDT 1999. Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Locally applied patches: @INC for perl 5.00503: Environment for perl 5.00503: |
From @tamiasOn Tue, Jul 23, 2002 at 11:10:03PM -0000, Ivan Tubert wrote:
This is by design, and as documented in perlre. In order to prevent For example: s/\w??/<$&>/g; would match zero characters at the start of the string over and over. This endless loop would not occur in your test program, since you only Ronald |
From ivan@ramana.chem.yale.edu
Thank you very much! I'm sorry I didn't notice that part of the Ivan |
From @hvdsRonald J Kimball <rjk@linguist.Thayer.dartmouth.edu> wrote: Note that the manner in which the information "I've already matched Hugo |
@hvds - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#15431 (status was 'resolved')
Searchable as RT15431$
The text was updated successfully, but these errors were encountered: