in reply to matching operator question
Depending on how many b's there are and where the last one is, that can be a lot more efficient than all those lookaheads. It also generalizes to patterns larger than a character, when the reverse solution would have to reverse the pattern as well, and the rindex wouldn't be able to pattern match at all. All in all, I'd say it's a pretty useful idiom to have in your toolbox.s/(.*)b/$1X/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: matching operator question
by Tanktalus (Canon) on May 13, 2005 at 23:38 UTC |