Regexes always give you the leftmost longest match. To do something like you want you best use the greediness of .* $string =~ s/(.*) two/$1/;
Update: I have simplified the unnecessarily complicated regex.
-- Hofmator
In reply to Re: Re: Substitute _last_ occurence in string?
by Hofmator
in thread Substitute _last_ occurence in string?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |