s/(.*)$tofind(.*)/$1$replacement$2/
It relies upon the greediness of the regex engine to match as much as possible as soon as possible.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: Replace the last letter
by CountZero
in thread Replace the last letter
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |