![]() |
|
Welcome to the Monastery | |
PerlMonks |
Re: Re: Substitute _last_ occurence in string?by Hofmator (Curate) |
on Jul 25, 2001 at 19:05 UTC ( [id://99701]=note: print w/replies, xml ) | Need Help?? |
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 Section
Seekers of Perl Wisdom
|
|