ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl5-porters
perl5-porters
Re: [BUG] [Regex] Is it a bug? Doing /\G(?=\<)/g twice.
by Zefram other posts by this author
Nov 4 2009 6:01AM messages near this date
Re: [BUG] [Regex] Is it a bug? Doing /\G(?=\<)/g twice. | [PATCH] Add assertions about there being no leftover scopes when enter perl_destruct.
Shlomi Fish wrote:
> print (($text =~ m{\G(?=<)}cg) ? "True" : "False");

Zero-width match.  perlre(1):

#  Repeated Patterns Matching a Zero-length Substring
...
#      Thus Perl allows such constructs, by forcefully breaking the infinite
#      loop.  The rules for this are different for lower-level loops given by
#      the greedy quantifiers "*+{}", and for higher-level ones like the "/g"
#      modifier or split() operator.
#
#      The lower-level loops are interrupted (that is, the loop is broken)
#      when Perl detects that a repeated expression matched a zero-length
#      substring.
...
#      Similarly, for repeated "m/()/g" the second-best match is the match at
#      the position one notch further in the string.

Not a bug.

-zefram
Thread:
Shlomi Fish
Demerphq
Zefram

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved