I am running some JavaScript code in Firefox that doesn't seem to be following the rules of regular expressions. I am trying to split up a String of coordinates, which has some funky whitespace in it, like so:
-117.2967917,35.5189858 -117.2966678,35.5189526
-117.296678,35.5187657 -117.2968027,35.5187999
-117.2967917,35.5189858
I know that the regex \s
is supposed to match all spacing, so I used \s+
to split my string in RegexPal, which worked great, as you can see below:
But for some reason when I run my JavaScript code with this regex, I get a one-element array with the entire String in it. This is my code:
var coordArray = polygonString.split("\s+");
I've tried several different regular expressions, but the split function in my JavaScript doesn't seem to be behaving like it should. It does not yield the same results at RegexPal. Why is this? What am I missing?