in reply to Re: Substitute _last_ occurence in string?
in thread Substitute _last_ occurence in string?

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