Reputation: 2901
I'm trying to find and replace all white spaces in a html file. Here's my code so far:
html.replace(@ (?![^<]*>|[^<>]*</)@g," ")
But above expression throws error as not a valid expression. How do I make it work?
Upvotes: 4
Views: 131
Reputation: 44145
Regexes are delimited by /
, not @
.
html.replace(/ (?![^<]*>|[^<>]*<\/)/g," ")
Here's another regex that literally replaces every white space with a non-breaking space:
html.replace(/\s+/g, " ");
Upvotes: 3