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.
In reply to Re: Substitute _last_ occurence in string?
by voyager
in thread Substitute _last_ occurence in string?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |