in reply to How do I replace a substring (if exists) with a different substring in a string?

With appropriate use of index, length and substr.

And remember that substr can be used as an lvalue.

  • Comment on Re: How do I replace a substring (if exists) with a different substring in a string?