使用 php 删除跨度标签的正则表达式 [英] Regex to remove span tags using php
本文介绍了使用 php 删除跨度标签的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是简单的 html,我想删除所有 span 标签,只需要 0.65 值.请有人帮助我.
Following is simple html i want to remove all span tag and just want 0.65 value. please someone help me on this.
<span class="smw smw-inline smw-basic smw-ct-default smw-visible" data-symbol="GSD.V" data-type="inline" data-refresh-frequency="5" data-source="live">
<span class="smw-market-data-field smw-field-l1" data-field="l1">0.65</span>
</span>
推荐答案
您可以使用 preg_replace('/<[^>]*>/', '', $content); 删除所有标签
而且你也可以只删除 span 标签 preg_replace('/<span[^>]+\>/i', '', $content);
使用这个:>
And also you can remove only span tag preg_replace('/<span[^>]+\>/i', '', $content);
using this:
<?php
$content = '<div><span class="smw smw-inline smw-basic smw-ct-default smw-visible" data-symbol="GSD.V" data-type="inline" data-refresh-frequency="5" data-source="live">
<span class="smw-market-data-field smw-field-l1" data-field="l1">0.65</span>
</span></div>';
echo $string = preg_replace('/<[^>]*>/', '', $content);
echo $new_string = preg_replace('/<span[^>]+\>/i', '', $content);
?>
这篇关于使用 php 删除跨度标签的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文