Skip to content

Instantly share code, notes, and snippets.

@neilkennedy
Created August 21, 2014 10:08
Show Gist options
  • Save neilkennedy/2878b53d5ae0525bffdb to your computer and use it in GitHub Desktop.
Save neilkennedy/2878b53d5ae0525bffdb to your computer and use it in GitHub Desktop.
Some JavaScript regex's to keep handy
.replace(/\s{2,}/g, ' ')//remove all double spaces with a single
.replace(/[ \t\r]/g, ''),//remove all whitespace
.trim()//remove leading and trailing spaces (supported IE9+)
"POINT (-0.159689 51.463423)".match(/(-?\d+(\.\d+)?)/g);//return the latitude & longitude from this WKT string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment