Replacing a string using Javascript replace function

Posted on 13-03-2017 by Nadir Latif


Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

The replace function can be used to replace a substring with another string using regular expressions.

For example: str.replace(/substring/g, 'New Substring'); will replace all occurrences of 'substring' with 'New Substring'