regex remove trailing spaces code example
Example 1: regex to remove spaces
//..
return str.replace(/\s/g, '');
//..
Example 2: regex ignore spaces
\s* ignore spaces
eg \s*yourregex\s*
Example 3: regular expression remove spaces
trim unnecessary whitespace