in reply to Re^5: Why my Regex doesn't work
in thread Why my Regex doesn't work
But I don't see any other zero-width assertions (besides lookarounds) that look like they would be helpful here. You can diddle with the match position outside of the regex engine to make it find overlapping matches. This matches three times:'ABABABA' =~ /ABA/g; # only matches twice #^^^ ^^^ here and here # ^^^ not here
You're right, though, regexes aren't the solution for every problem. In particular, highly structured text (like HTML or program source code) can be difficult to manipulate with regexes alone.$_ = 'ABABABA'; while (/ABA/g) { print pos($_), "\n"; pos($_)--; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Why my Regex doesn't work
by choroba (Cardinal) on Apr 12, 2017 at 09:11 UTC |