Replacing text node of HTML input in PHP
Posted
by
Aman Kumar Jain
on Stack Overflow
See other posts from Stack Overflow
or by Aman Kumar Jain
Published on 2010-12-24T07:27:55Z
Indexed on
2010/12/24
8:54 UTC
Read the original article
Hit count: 270
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?
© Stack Overflow or respective owner