My Code is given below,
var str = '<p>(a) test <span style="text-decoration: line-through;">
test</span> <span style="font-family: arial, helvetica, sans-serif;">
123 test <span style="font-family: SutonnyMJ;"> test test
<span style="background-color: #008000;">test <span style="background-color: #ffffff;">
test <span style="color: #800080;">test</span></span></span></span></span></p>
<table style="height: 43px;" width="250"><tbody><tr><td>test</td>
<td>test</td></tr></tbody></table>';
for(var eq in G){
var an=new RegExp(eq,"g");
str=str.replace(an,G[eq]); //For Example an = /t/g and G[eq] = a For One Index
}
If i use this string without HTML Tag , the result is perfect.
I want to make a regular express pattern -
1. it will not replace any HTML Tag(
Example:<p>,</p> <div>,</div>, ,<br/>,<span>,</span>,<table>,</table> and etc)
and HTML Tag Atrribute(Example : style etc).
2. it will not replace inner/element of HTML Tag(Eexample : span,div etc) if font-fmaily
is not SutonnyMJ (font-family: SutonnyMJ) in style attribute ;
I assume that test will be abca after replace.
The Result String is given below ,
result_str ='<p>(a) abca <span style="text-decoration: line-through;">
abcd </span> <span style="font-family: arial, helvetica, sans-serif;">
123 test <span style="font-family: SutonnyMJ;"> abca abca
<span style="background-color: #008000;">abca <span style="background-color: #ffffff;">
test <span style="color: #800080;">abca</span></span></span></span></span></p>
<table style="height: 43px;" width="250"><tbody><tr><td>abca</td>
<td>abca</td></tr></tbody></table>';
In result_str 123 test is not change because it's parent style font family is not SutonnyMJ
How to write a JavaScript regular expression pattern. Please any suggestion?