我做了preg_replace:php正則表達式或|運營商
$pattern = '/<ul>/';
$replacement = "";
$string = "hello <ul> how are you doing </ul>";
echo preg_replace($pattern, $replacement, $string);
,將取代我<ul>
與""
但我還想來代替任何一個<ul>
或</ul>
,我沒有得到如何,雖然使用|
(或)字符。
我嘗試這樣的,但它不工作的權利:
$pattern = '/<ul>|</ul>/';
$replacement = "";
$string = "hello <ul> how are you doing </ul>";
echo preg_replace($pattern, $replacement, $string);
任何幫助,將肯定讚賞
感謝, 布萊恩
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – 2011-01-20 04:07:45