1
Link to the site where I tested regex
I test on the site and works correctly the goal is to have 2 numbers as coordinates 12.0,34.0 and receive the valid answer but I am receiving in my invalid log.
var string = "12.0,34.0";
var re = new RegExp("[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+))?");
if (re.test(string)) {
console.log("Valida");
} else {
console.log("Invalida");
}
Remembering what appears on my console is invalid ! I have tested with other simpler expressions and it works perfectly the code if anyone knows the solution is that I know little or nothing about regex
The strings you are testing may have junk or only numbers + comma + numbers and what you need is to know if it is a valid coordinate?
– Sergio
only numbers with . and a comma the regex was not correct but now I’ve modified it and everything is working fine
– Rakav