Javascript Regex - Remove single spaces NOT double spaces -
i need remove singles spaces string not double spaces.
using regex i've tried this, invalid , i'm not sure how fix it:
\s+{1,1}   this want achieve:
raw string:
"okay,  let ’s   star ted,  bret t "   after regex replace (keeping double spacing):
"okay,  let’s   started,  brett"      
since javascript doesn't support lookbehinds, believe have to can resort callback function: 
str = str.replace(/\s+/g, function(m) {     return m.length === 1 ? '' : m; });      
Comments
Post a Comment