获取字符串中数字的正则表达式
时间:2021-07-01 10:21:17
帮助过:6人阅读
- $patterns = "/\d+/"; //第一种
- //$patterns = "/\d/"; //第二种
- $strs="left:0px;top:202px;width:90px;height:30px";
- preg_match_all($patterns,$strs,$arr);
- print_r($arr);
-
- /***************运行结果*********************/
- //第一种
- Array
- (
- [0] => Array
- (
- [0] => 0
- [1] => 202
- [2] => 90
- [3] => 30
- )
- )
- //第二种
- Array
- (
- [0] => Array
- (
- [0] => 0
- [1] => 2
- [2] => 0
- [3] => 2
- [4] => 9
- [5] => 0
- [6] => 3
- [7] => 0
- )
- )
|
正则表达式