好的,我嘗試了2個小時。現在是時候在stackoverflow詢問一些人了。匹配除了給定字符串以外的所有內容
我有這樣的HTML源文件:
<div class="post_main">
Post Content (has HTML)
</div><div class="post_email">[...]
Other Stuff
<div class="post_main">
Post Content (has HTML)
</div><div class="post_email">[...]
Other Stuff
<div class="post_main">
Post Content (has HTML)
</div><div class="post_email">[...]
等。 我想在每個帖子內容前加上「Something」。
爲此,我使用了preg_replace,但它不起作用。由於我使用
'|<div class="post_main">(.*)</div><div class="post_email">|s
由於正則表達式中,
"</div><div class="post_email">"
實際上從吃(。*),我只有一個替代,而不是3
現在,如何我能得到這個預浸比賽:包括
比賽寄託都換行,但不包括給定的字符串(在這種情況下:
"</div><div class="post_email">")
?
非常感謝。
這只是工作。我是這樣做的:D – cedivad 2010-11-08 15:22:37