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?
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, " "); replace() to a variable? Please provide a minimal reproducible example.
/to delimit regex literals.