Regex lookahead example not as stated in Camel 4th

Gianni Ceccarelli dakkar at
Wed Jun 19 15:51:27 BST 2013

On 2013-06-19 Bob MacCallum <uncoolbob at> wrote:
> so, forgetting the typo for a moment, why doesn't it output
> 012
> 012
> 012
> 012
> ...
> ?
> From my reading of the 5.12 perlre docs, there is no mention of
> moving the cursor along by one position after each match.  Maybe
> that is a more general thing I wasn't aware of.

L<perlre/Repeated Patterns Matching a Zero-length Substring>

Summary: since C<//g> would be an infinite loop, Perl breaks it for
you, advancing the C<pos()> by one after each (0-len) match.

	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88

Beware of Programmers who carry screwdrivers.
		-- Leonard Brandwein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url :

More information about the mailing list