Closed ahoiroman closed 7 years ago
Hello,
I am looping through a HTML string as follows:
foreach ( $dom->find( 'text' ) as $element ) { if ( !in_array( $element->parent()->tag, $excludedParents ) ) { $element->innertext = preg_replace( '/(?<!\w)' . preg_quote( $search, "/" ) . '(?!\w)/i', $replace, $element->innertext ); } }
This works fine for excluded parents like a, div or em, but not for a.test or div#test. Is there an elegant way to solve that?
a
div
em
a.test
div#test
Hello,
I am looping through a HTML string as follows:
This works fine for excluded parents like
a
,div
orem
, but not fora.test
ordiv#test
. Is there an elegant way to solve that?