You can remove the (redundant) .* from Roy Johnson's.
I don't know if it helps any, but you can remove the lookahead too:
s/(fox(?:(?!fox).)*forest)/the $1/;
In reply to Re^3: regexp find last word
by ikegami
in thread regexp find last word
by Murcia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |