I have a regular expression that I need to match which searches for a Latitude Longitude point in a couple of different formats. The problem with this is that it will match partial coordinates out of numbers that shouldn't work as coordinates.
Regex:
([1-8]?[0-9]\.[\d]{1,10}|90\.0+|0\.[\d]{1,10})\s?°?\s?[NS]?\s?\,\s*(([1][8][0]\.0+)|(([0-9]|[1-9][0-9]|1[0-7][0-9]|[0])\.[\d]{1,10}))\s?°?\s?[EW]?
For Example, the above regex will match 90.0000, 180.0000 out of the string "190.0000, 180.0000" which isn't a valid coordinate. The way I've come up with to combat this is placing the Regex inside non-digit character matches:
[^\d]...regex...[^\d]
which works like a charm.
The problem with this is now the digits are included in the match and when I am searching for multiple matches it starts skipping coordinates that only have one white space in between them (like a new line).
So when searching through the string:
"90.0000°, 180.0000°
78.4566°, 177.4444°
12.12345N, 80.676667E"
it will skip 78.4566°, 177.4444°.
My Question is:
Is there a way to match the coordinate (in between two [^\d] but don't include [^\d] in the match so the regex search will begin testing the next match at the last [^\d] in the last match?
-Kyle
This is for a VB.Net 3.5+ Regex