Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This can't work, because the first \1 will be always set to the last match ahead (and undef or "" at first encounter)
This is because $1 is a global var will keep match instead of erasing when backtracking. FWIW I tried something similar by capturing the following character in $2 for the next run: m/ ^ (?:(?!\2).)*? (.) (?=(.|$)) (?!.*\1) /x But couldn't get it to work, probably because the regex engine is not considering another defined \2 while backtracking. (or probably b/c I was too tired last night)
probably I'm having a bug in my logic, experts to the rescue! ;-) Didn't have the time yet for proper debugging.
Cheers Rolf
In reply to Re^2: Regex: matching character which happens exactly once (using global memory)
by LanX
|
|