2

我有这个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] => 数组 ( ) [6] => 数组 ( ) )

当我只尝试 preg_match 时,它根本不起作用,我错过了什么吗?

我正在搜索 GB 货币值的字符串。

4

1 回答 1

0
$cash = "hi £240";
preg_match_all("/£(?P<amount>\d*,?\d*\.?\d*)/",$cash,$match);

print_r($match['amount']);
于 2013-02-12T09:36:30.010 回答