Summary. Use the replace() method to return a new string with a substring replaced by a new one . Use a regular expression with the global flag ( g ) to replace all occurrences of a substring with a new one.
Summary. Use the replace() method to return a new string with a substring replaced by a new one . Use a regular expression with the global flag ( g ) to replace all occurrences of a substring with a new one.