in reply to Substitute _last_ occurence in string?
Reverse the string, remove the reverse of the desired token, then reverse the result.$string = "one two three two four"; $gnirts = reverse $string; $gnirts =~ s/ owt//; $string = reverse $gnirts;
Update: Full disclosure -- this was motivated by a node on sexeger I saw before. Props to japhy.
Update2: Fixed typo -- thanks Hofmator.
|
|---|