gpt4 book ai didi

php正则表达式删除mso标签

转载 作者:行者123 更新时间:2023-12-04 05:53:33 24 4
gpt4 key购买 nike

我有这个 html 代码:

$html = "<P style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; padding: 4px;" class=MsoNormal>text</P>";

我需要删除所有 mso-* 标签,结果将是:
$html = "<P style="padding: 4px;" class=MsoNormal>text</P>";

我怎么能用php??
非常感谢

最佳答案

代码:

$html = "<p style='mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; padding: 4px;' class=MsoNormal>text</P>";

$cleanHtml = preg_replace('(mso-[a-z\-: ]+; )i', '', $html);

echo $cleanHtml;

输出:
<P style='padding: 4px;' class=MsoNormal>text</P>

关于php正则表达式删除mso标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9785908/

24 4 0