php中如何将
$155.75 字符串中
155.75提取出来呢??
完整的表达式应该怎么写??
谢谢大家哦!
给奖励!
第1个回答 推荐于2016-08-18
<?php
$str = "sssefss$2345.1234dddfffeds$456$00.23RR";
$pattern = '/\$(\d+\.?\d+)/';
if(preg_match_all($pattern, $str, $match)){
echo '<pre>';
print_r($match);
}else{
echo '没有找到!';
}
结果:
Array
(
[0] => Array
(
[0] => $2345.1234
[1] => $456
[2] => $00.23
)
[1] => Array
(
[0] => 2345.1234
[1] => 456
[2] => 00.23
)
)本回答被提问者和网友采纳
$str = "sssefss$2345.1234dddfffeds$456$00.23RR";
$pattern = '/\$(\d+\.?\d+)/';
if(preg_match_all($pattern, $str, $match)){
echo '<pre>';
print_r($match);
}else{
echo '没有找到!';
}
结果:
Array
(
[0] => Array
(
[0] => $2345.1234
[1] => $456
[2] => $00.23
)
[1] => Array
(
[0] => 2345.1234
[1] => 456
[2] => 00.23
)
)本回答被提问者和网友采纳
第2个回答 2015-05-07
\D*(\d+\.?\d?)\D*
匹配到括号里面的是数字
匹配到括号里面的是数字
第3个回答 2015-05-07
直接把$去掉不就ok了,还搞正则干嘛
str_replace('$','',$str);
str_replace('$','',$str);
第4个回答 2015-05-07
\d+\.\d+ 试试