/ Published in: JavaScript
small handy snippet to single space a string in javascript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// single space a string in javascript - Topcat Software LLC - 2010 // http://www.topcat.hypermart.net/index.html // before: str = " when harry met sally " // after: str = "when harry met sally" str.replace(/^\s+|\s+$/g,'').replace(/\s\s+/g,' ')
URL: http://www.topcat.hypermart.net/index.html