'tmap 116.123456,39.123456‘
tmap后面有空格,
我想获取116.123456
和39.123456两个浮点坐标,请问怎么用正则获取?
$str = 'tmap 116.123456,39.123456';preg_match_all('/[^\s]+/', $str, $match);$numstr = $match[0][1];print_r(explode(',',$numstr));
$s = 'tmap 116.123456,39.123456';preg_match_all('/[\d.]+/', $s, $r);print_r($r[0]);Array( [0] => 116.123456 [1] => 39.123456)
$s='tmap 116.123456,39.123456';$ar = preg_split('/[\s,]+/',$s);print_r($ar);
$str = 'tmap 116.123456,39.123456';print_r(preg_split('/[\s,]/', $str));
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号