Help: How does PHP use the regular to get floating-point numbers?
' TMap 116.123456,39.123456 '
There are spaces behind the TMap,
I want to get 116.123456
and 39.123456 two floating-point coordinates, how can I get it with a regular?
------Solution--------------------
$str = ' TMap 116.123456,39.123456 ';
Preg_match_all ('/[^\s]+/', $str, $match);
$numstr = $match [0][1];
Print_r (Explode (', ', $numstr));
Array
(
[0] = 116.123456
[1] = 39.123456
)
------Solution--------------------
$s = ' tmap 116.123456,39.123456 ';
Preg_match_all ('/[\d.] +/', $s, $r);
Print_r ($r [0]);
Array
(
[0] = 116.123456
[1] = 39.123456
)
------Solution--------------------
$s = ' tmap 116.123456,39.123456 ';
$ar = Preg_split ('/[\s,]+/', $s);
Print_r ($ar);
------Solution--------------------
$str = ' TMap 116.123456,39.123456 ';
Print_r (Preg_split ('/[\s,]/', $str));