PHP Preg expression to remove html tags and internal content from a string?

quick question.

I would like to remove the sup tag from the next line and all the contents inside it.

$string = "Priority Mail<sup>&reg;</sup> International";

How should I do it?

+3
source share
2 answers

I assume something like this will work:

preg_replace("(<([a-z]+)>.*?</\\1>)is","",$input);
+6
source
$string = preg_replace ("/<sup>(.*?)<\/sup>/i", "", $string);

You should know that (. *?) Cannot deal with \ n or \ r, so filter them first.

+1
source

All Articles