// /g replaces all occurrences of "text" in str
str.replace(/text/g, 'something');
The RegExp W Metacharacter in JavaScript is used to find the non word character
//i.e. characters which are not from a to z, A to Z, 0 to 9. It is same as [^a-zA-Z0-9].
/g finds all the matches for the given regex