Your skill will accomplish what the force of many cannot |
|
PerlMonks |
(dkubb) Re: (3) Answer: How do I replace a substring (if exists) with a different substring in a string?by dkubb (Deacon) |
on Jul 22, 2001 at 02:00 UTC ( [id://98706]=note: print w/replies, xml ) | Need Help?? |
Note: I found a bug in my earlier answer, since I can't edit it, I am posting this follow up. If the string to replace has the substring you are trying to find, it can get into an endless loop. Here is an updated ansewer:
In this case, an s/// regex is actually 5% faster.
In Section
Seekers of Perl Wisdom
|
|