⭐ in reply to How do I delete the last instance of a word from a string?
or, to avoid removing the last character of the string when $word is not present:substr($string,rindex($string,$word),length($word)) = '';
my $ri = rindex($string,$word); substr($string,$ri,length($word)) = '' if $ri > -1;
Edit by tye to incorporate reply
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I delete the last instance of a word from a string?
by suaveant (Parson) on Oct 30, 2001 at 19:24 UTC |