首页 > 代码库 > php 正则提取数字
php 正则提取数字
<?php
//$patterns = "/^(http|https):\/\/(.)*\.(.)*$/";
$patterns = "/\d+/";
$strs="23345swwyuiopbfASWEDD4667";
preg_match_all($patterns,$strs,$arr);
print_r($arr);
?>
Array
(
[0] => Array
(
[0] => 23345
[1] => 4667
)
)
<?php
//$patterns = "/^(http|https):\/\/(.)*\.(.)*$/";
$patterns = "/\d/";
$strs="23345swwyuiopbfASWEDD4667";
preg_match_all($patterns,$strs,$arr);
print_r($arr);
?>
Array
(
[0] => Array
(
[0] => 2
[1] => 3
[2] => 3
[3] => 4
[4] => 5
[5] => 4
[6] => 6
[7] => 6
[8] => 7
)
)
<?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
)
)
php 正则提取数字
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。