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/
In reply to Re: matching operator question
by TimToady
in thread matching operator question
by redss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |