[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Puzzle thread on clpmod




Andy Jacobs wrote:
> > while ( /[a-e](?=[a-e]{4})/g ) {
> 
> Wouldn't
> 
> 	while ( /([a-e]{5})/g ) {
> 
> have done the job, without an explicit look-ahead?

No, because after a match, the /g will cause the next search to
begin after the entire matching five-character substring.
But we want to step through the string one character at a time,
even when there was a match.

Example:

"eeeeabcdzz"

First, "eeeea" will match (but then will be rejected by the inner
tests); then we want the next match to be "eeeea", not "bcdzz".

John Porter


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe