2013-03-10 22 views
3

要匹配除指定字符之外的任何字符(在本例中爲「f」),我使用[^f]+PHP preg_match除字之外的任何字符

但如何匹配除指定字外的任何字符?喜歡的東西[^word]+

例子:

草垛"bla1 bla2 bla3 bla4 hello bla5 bla6 bla7"(草垛包含HTML和換行符)

"bla1 bla2 bla3 bla4 "

所以我想抓住一切從開始直到"hello"

+0

你有沒有試過..你知道..只是做[^字]? – christopher 2013-03-10 10:54:51

+0

這將匹配什麼包含字母w,o,r,d ... – Martin 2013-03-10 10:55:16

+0

你在找[Assertion](http://php.net/manual/en/regexp.reference.assertions.php) – 2013-03-10 10:55:48

回答