0

I`ve been trying to extract doubles (positive or negative) from a string with regex patterns, but the one that works better just gets the positive ones.

Pattern p = Pattern.compile("(\\d+(?:\\.\\d+))");
Matcher m = p.matcher(str);

This is Java code.

Heres an example of what Im trying to work with:

https://www.google.es/maps/dir/6.1521026,-75.6158273/6.1769038,-75.5853826/6.150728,-75.5312788/6.2007872,-75.5786226/6.236831,-75.5706288/6.1868153,-75.5914233/6.1742041,-75.3394911/6.2646443,-75.5684491/6.2541748,-75.4211777/@6.2402553,-75.6186275,11z/data=!3m1!4b1

Do you now how to add negative doubles to the ecuation?

Thanks!

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • It doesnt work :/ If I trow this: https://www.google.es/maps/dir/6.1521026,-75.6158273/6.1769038,-75.5853826/6.150728,-75.5312788/6.2007872,-75.5786226/6.236831,-75.5706288/6.1868153,-75.5914233/6.1742041,-75.3394911/6.2646443,-75.5684491/6.2541748,-75.4211777/@6.2402553,-75.6186275,11z/data=!3m1!4b1 Result with the one that im using: 6.1521026 75.6158273 6.1769038 75.5853826 6.150728 75.5312788 6.2007872 75.5786226 6.236831 75.5706288 Result with that one: null null null ... – Diego Giraldo Nov 14 '16 at 07:34
  • [Check this demo with `-?\\d+\\.\\d+` as regex](https://regex101.com/r/YO7v0m/1) – anubhava Nov 14 '16 at 10:21

0 Answers0