Regular Expression to replace content only in html part
As this (<.+?> ) expression is use to detect the html part.
Now I want invers of this to replace content only in html part.
For Example suppose there is paragraph in which we are searching and replacing some text.
Problem is if that paragraph contains another html tag such as heading tag with some text.
For eg.
<p id="para1">
hello world.
<h1>hi how are you ?</h1>
</p>
Now Suppose I want to replace h with b.
Var regex=/h/g;
Var str=document.getElementById("para1") . innerHTML;
str=str.replace(regex,"b") ;
document.getElementById("para1").innerHTML=str;
This code replace the text in paragraph i.e h
As well as the h of heading tag also i.e <h1> and </h1>
So plz give solution how I can avoid the html tags while replacing text.