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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -