解决方案 »

  1.   

    1、echo preg_replace('/<[^>]+>[^<>]*微信号[^<>]*<[^>]+>/u', '', $content);2、$content    = preg_replace('/<img([^>]+)src=["\']http[s]?:\/\/www\.aabbcc\.com\/upload\/qrcode_for_gh_2ff16e7c9789_258\.jpg["\'](.*?)>/is', '', $content);
      

  2.   

    $content = "0000<div>111<div>222<div>这里有很多其他字符、表单等等....微信号...这里有很多其他字符、表单等等</div>222</div>111</div>0000";
    $content = preg_replace('/<[^>]+>[^<>]*微信号[^<>]*<[^>]+>/', '', $content);// 去掉修饰符就可以了
      

  3.   

    <div><span style="word-wrap: break-word; font-weight: 700; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">
    <font style="word-wrap: break-word; background-color: yellow;">扫描二维码</font>
    或直接搜索微信号:<font style="word-wrap: break-word; background-color: yellow;">&nbsp;mcq28tui</font>
    </span></div>
    <[^>]+>[^<>]*微信号[^<>]*<[^>]+>匹配到的结果是</font>
    或直接搜索微信号:<font style="word-wrap: break-word; background-color: yellow;">
    怎么匹配到span标签(匹配到微信号所在的最近的标签)?