remove white space from string in javascript regex code example Example: remove whitespace with regex javascript return str.replace(/\s/g, '');