我在與這似乎是匹配1個小數點的數字,例如1.20,2.50正則表達式的問題,但不是數字,如20.50或906.10捕獲數是大於1位小數
這裏是正則表達式
/(?:site(?:\\.com)?[\\s\\w\\d^]*)(\\d+\\.\\d{2})/i
我也試過以下的正則表達式,但它似乎錯過較小的數字
/(?:site(?:\\.com)?[\\s\\w\\d^]*)(\\d+\\d+\\d+\\.\\d{2})/i
與更換d
0似乎不起作用
字符串
Debit card payment to site.com
Germany
on 01 May 1.30
Debit card payment to site Germany
on 01 May 4.63
Debit card payment to site.Com
Germany
on 01 May 3.30
Debit card payment to Paypal *Xiao
Ref:- 23948 0000000000 32.98
Debit card payment to site.Com
Germany
on 20 May 17.49
Debit card refund from site.Com
Germany
on 21 May 429.29
任何幫助,將不勝感激謝謝。
參考:
$re = "/(?:site(?:\\.com)?[\\s\\w\\d^]*)(\\d+\\.\\d{2})/i";
$str = "Debit card payment to site.com
Germany
on 01 May 1.30
Debit card payment to site Germany
on 01 May 4.63
Debit card payment to site.Com
Germany
on 01 May 3.30
Debit card payment to Paypal *Xiao
Ref:- 23948 0000000000 32.98
Debit card payment to site.Com
Germany
on 20 May 17.49
Debit card refund from site.Com
Germany
on 21 May 429.29 ";
preg_match_all($re, $str, $matches);
print_r($matches)
應該是預期的輸出? – 2015-02-01 00:55:46
'/(?: site(?:\\。com)?)。*?\ b(\ d \。\ d {2})/ isg'應該這樣做。 – 2015-02-01 00:59:04