Original post

As programmers we often need to take a string and replace parts of it with something else. The code below has three examples, first of which is a basic ‘find all’ and replace, the second changes only the first occurrence of ‘sound’ and finally the third example demonstrates how to change a string containing quotes to use escaped quotes. These are changed by using the 4th argument to define how many times to replace, with -1 being everytime.