我有preg_match_all
:
$cash = "hi £240";
preg_match_all("/^£?(([1-9]{1,3}(,\d{3})*(\.\d{2})?)|(0\.[1-9]\d)|(0\.0[1-9]))$/", $cash, $matches);
print_r($matches);
print_r返回:
数组([0] =>数组()[1] =>数组()[2] =>数组()[3] =>数组()[4] =>数组() [5] => Array()[6] => Array())
当我尝试使用preg_match时,它根本没用,我错过了什么吗?
我正在搜索字符串中的GB货币值。
答案 0 :(得分:0)
$cash = "hi £240";
preg_match_all("/£(?P<amount>\d*,?\d*\.?\d*)/",$cash,$match);
print_r($match['amount']);