in reply to Substitute _last_ occurence in string?
Or for searching for strings (this does not work for patterns) you can use rindex:
my $string = 'one two three two four'; my $search = 'two '; substr($string, rindex($string,$search), length $search, ''); print $string;
-- Hofmator
|
|---|