regex remove new line and spaces code example Example: regex to remove spaces //.. return str.replace(/\s/g, ''); //..