How does php obtain floating point numbers using regular expressions?

Source: Internet
Author: User
How does php obtain floating point numbers using regular expressions? 'Tmap 116.123456, 100'
There is a space behind tmap,
I want to get 116.123456
And 39.123456 floating point coordinates. how can I obtain them using regular expressions?

Reply to discussion (solution)

$str = 'tmap 116.123456,39.123456';preg_match_all('/[^\s]+/', $str, $match);$numstr = $match[0][1];print_r(explode(',',$numstr));

[0] = & gt; 116.123456
[1] => 39.123456.

$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));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.