/ Published in: JavaScript

Trims leading and trailing spaces from a string value and returns the result as a new string.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function trimWhitespace(value) { var result = value.match(/^\s*(.*\S)\s*$/); if (result !== null && result.length === 2) return result[1]; else return value; };
Comments
