Javascript Regex Replace HTML Tags
html, javascript, jquery, regex
Solution
That's because you're escaping the wrong thing, as only the backslash needs to be escaped.
newhtml = newhtml.replace(/<div>/g,'<br>');
newhtml = newhtml.replace(/<\/div>/g,' ');
Problem
Having a lot of difficulties using regex. Heres what i am trying to do... ``` text<div> text </div><div> text </div><div> text </div> ``` to turn it in to ``` text<br> text<br>text<br>text ``` I've tryed doing... ``` newhtml = newhtml.replace(/\<div>/g,'<br>'); newhtml = newhtml.replace(/\</div>/g,' '); ``` but this gives the wrong output. Does jquery provide a better way of doing this?