我試圖讓整個句子:preg_match_all匹配整個句子
PRICE CHANGE this this : this var1 : this/this (this) var2,var3 : 111,11 Price(€) : 1.021 start from : 2012-07-26 18:15:00
來源:
timezone. PRICE CHANGE this : this var1 : this/this(this) var2, var3 : 119, 111 Price(€) : 5.021 start from : 2012-07-26 18:15:00 PRICE CHANGE this : this this2 var1 : this (this) var2, var3 : 1604, 452 Price(€) : 6.014 start from : 2012-07-26 18:15:00 bla bla bla bla.
使用此:
body = "timezone. PRICE CHANGE this : this var1 : this/this(this) var2, var3 : 119, 111 Price(€) : 5.021 start from : 2012-07-26 18:15:00 PRICE CHANGE this : this this2 var1 : this (this) var2, var3 : 1604, 452 Price(€) : 6.014 start from : 2012-07-26 18:15:00 bla bla bla bla."
$test = preg_match_all('/PRICE CHANGE\s*(.*?)*(\d+:\d+:\d+)', $body, $result);
而且它不工作, 幫幫我?
你錯過了你的最後/和(。*?)*沒有意義,我也不確定是否「。 「會匹配一個」€「,試試'/ PRICE CHANGE \ s +([\ s \ S] *?)(\ d +:\ d +:\ d +)/ gi' –
不要緊,用$ test ='preg_match_all '/價格變化\ s *(\ s + \ S + \ D + \ w + \ W +)*(\ d +:\ d +:\ d +)/',$ body,$ result);'thanks! –
and urs solution works fine too too @shhac!謝謝! –