So I have this problem for some reason some times I’m getting a string with two n/ n/ signs between first <p> and <p><p>
, how could try to catch it and remove it?
look like this if I paste it
JavaScript
x
4
1
string = '<p>
2
3
</p><p><span style="color: rgb(114, 114, 114);text-align: justify">Tutorials</span><br></p><p></p>'
4
if I look at this string from debugger then I see it like <p>nn<p><p>
so basicaly I need to check if nn is between <p> and <p><p>
then i have to remove it.
Advertisement
Answer
Use string method replace:
JavaScript
1
2
1
s = s.replace("<p>nn</p><p>", "<p></p><p>")
2
(or whatever you need replacing)