0

All,

I have created below regex (javascript regex) for validating geo location coordinates as follows:

(42.969142, -81.237232)
(42, -81)
(-42, +81)
etc

I have the following regex expression that works in an online validator but doesn't work in the browser, please help:

Regex:

\([-+]?\d+(\.\d+)?\s*\,\s*[-+]?\d+(\.\d+)?\)

Tested here and it works:

http://www.regextester.com/

My javascript code:

var regexCoords = "\([-+]?\d+(\.\d+)?\s*\,\s*[-+]?\d+(\.\d+)?\)";
    var regex = new RegExp(regexCoords);
    var validCoords = regex.test(streetAddr);
ActiveX
  • 1,064
  • 1
  • 17
  • 37

0 Answers0