Replacing text node of HTML input in PHP
- by Aman Kumar Jain
Hi,
I want to replace all the text nodes in a html text. I'll explain with an example:
$html = "
<div>
<p>
text2 text2 word text2
<span>abcd</span>
text2 text2 word text2
<p>
this is a long, very long statement with punctuations.
</div>
I want to replace "text2 text2 word text2" with "<span>text2 text2 word text2</span>" and "this is a long, very long statement with punctuations." with "<span>this is a long, very long statement with punctuations.</span>"
What should be the regular expression for the same?