This can be expressed a little bit simpler: $string=~s/(.*) two/$1/; The /g modifier is not necessary - there will be only one match. And you don't want to change anything after the match so you don't have to capture and replace it.
-- Hofmator
In reply to Re: Re: Substitute _last_ occurence in string?
by Hofmator
in thread Substitute _last_ occurence in string?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |