how to remove whitespace from one end of a string in javascript code example Example: remove whitespace with regex javascript return str.replace(/\s/g, '');