var string="removespace : dont remove spaces";
need a regex which replaces all spaces before and after colon ':' .
above variable must be returned as
"removespacedont remove spaces"
var string="removespace : dont remove spaces"; var str = string.replace(/\s+:\s+/g, ''); //insert colon : in the '' if you want the colon left in alert(str);
thanks