问题
quick question.
I'd like to remove the sup tag from the following string, and all content within it.
$string = "Priority Mail<sup>®</sup> International";
How would I do that?
回答1:
I imagine something like this would work:
preg_replace("(<([a-z]+)>.*?</\\1>)is","",$input);
回答2:
$string = preg_replace ("/<sup>(.*?)<\/sup>/i", "", $string);
You should know that (.*?) can't deal with \n or \r, so filter them first.
来源:https://stackoverflow.com/questions/10508801/php-preg-expression-to-remove-html-tags-and-inner-contents-from-string