in reply to Replace the last letter

What about

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