in reply to Re: Replace zero-width grouping?
in thread Replace zero-width grouping?
I hoped to fix the two-pass version by adding a check to make sure this character wasn't already earmarked to become a "B" before accepting it to become an "A":
but that still fails in exactly the same way, because the regexp engine goes to some effort to make sure that the pattern is matched against the original unmodified string each time through an s///g.s/(?<!A...)(.)(?=...\1)/A/g; s/(?<=A...)(.)/B/g;
It is also unfortunate that s/// doesn't have the same support for things the //gc flags - it would have been handy to be able to solve this with something like:
pos($_) -= 3 while s/(.)(...)\1/A$2B/gc;
Hmm, frustrating - I feel sure there must be a simple and efficient solution.
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Replace zero-width grouping?
by Enlil (Parson) on May 07, 2003 at 08:14 UTC | |
|
Re: Re: Re: Replace zero-width grouping?
by BrowserUk (Patriarch) on May 07, 2003 at 02:24 UTC |