如何修改以下正則表達式是如果<img>
標籤內<script>
標籤不執行(分別爲<script language="...">
,意爲<script*>
)正則表達式表達對圖像
代碼:
function seo_friendly_images($content) {
return preg_replace_callback('/<img[^>]+/', 'seo_friendly_images_process', $content);
}
add_filter('the_content', 'seo_friendly_images', 100);
[你試過一個HTML解析器嗎?](http://stackoverflow.com/a/1732454/476) – deceze
我正在研究它,這是有條件的去正確的方式,如果(stripos($ content,'<腳本')!==假){ –
[你不應該使用正則表達式。](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained -tags/1732454#1732454)但是,[您的問題與此類似。](http://stackoverflow.com/questions/12554005/c-sharp-regex-replace-in-string-only-outside-tags) –