0

特定の HTML ドキュメントからすべてのアスタリスクを削除したいと考えています。ただし、ul-tag 内にあるもののみ。これらの ul-tag の中には、クラスを持つものもあります。何時間も自分自身を試した後、私は尋ねることにしました。

助けてくれてありがとう。

4

2 に答える 2

0

これを試すことができますか:

<ul[^>]*?>(.*?[*]+.*?)*</ul>
于 2012-09-17T13:09:18.037 に答える
0

必要なものは次のとおりです。

<?php

// a function to remove any asterisks from a string
function replace_asterisks($replace){
    return str_replace('*', '', $replace[0]);
}

$html = '* blah blah * * <ul>blah<li>*</li>*</ul> sad sad <ul>**</ul>';

// if found any <ul> with asterisks, pas the part to that function to remove asterisks from it
$html = preg_replace_callback('/<ul.*?>.*?\*.*?.*?<\/ul>/', 'replace_asterisks', $html);

echo $html;

?>
于 2012-09-17T13:33:57.683 に答える