Trying to get rid of any space that is around a non-alphanumeric character without removing the said character like /\s*(\W)\s*/g
would by default.
Is there a way to target only the spaces with .replace()?
e.g.:
var regex = "/\s*(\W)\s*/g";
var text = "Words : \" text docs\"";
var text = text.replace(regex , "");
console.log(text)
expected text :"Words:"text docs"
Something like remove white spaces between special characters and words python but in javascript