in reply to How do I replace a substring (if exists) with a different substring in a string?
I think, this is a much neater way to do it, however I do not know how fast it is or how much more memory it uses. I have found that in JavaScript, this method works faster than the regular replace() method. Generally, working with arrays in JavaScript is always faster than working with strings. Btw could somebody do a benchmark on this to see how it compares to the other solutions?$string = join( $replace, split($find, $string) );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I replace a substring (if exists) with a different substring in a string?
by choroba (Cardinal) on Jun 25, 2016 at 20:26 UTC | |
|
Re: Answer: How do I replace a substring (if exists) with a different substring in a string?
by choroba (Cardinal) on Jun 25, 2016 at 19:57 UTC | |
|
Re: How do I replace a substring (if exists) with a different substring in a string?
by harangzsolt33 (Deacon) on Jun 26, 2016 at 03:04 UTC |