String.prototype.replaceAll
provides an easy way to replace all occurrences of a substring without creating a global RegExp.
const queryString = 'q=query+string+parameters'; // Works, but requires escaping inside regular expressions. queryString.replace(/\+/g, ' '); // → 'q=query string parameters' // Simpler! queryString.replaceAll('+', ' '); // → 'q=query string parameters'
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.