I need to extract the different components from a GPS coordinate string. So for example:
+30° 18' 12" N // pull out 30, 18 & 12
or
+10° 11' 1" E // pull out 10, 11 & 1
or
-3° 1' 2" S // pull out -3, 1 & 2
or
-7° 12' 2" W // pull out -7, 12 & 2
I have had a look around online and I notice there is the NSRegularExpression. I was wondering if it's possible to use this in some way? I have also had a look at the documentation provided and I have tried to put together a regex to pull out the different parts. This is what I came up with:
('+'|'-')$n°\s$n'\s$n"\s(N|E|S|W)
I'm not really sure if this is correct or not, I'm also unclear on how to use it since there aren't many tutorials/example around. Please could someone help me out? If there is a better way of doing this rather than using NSRegularExpression I'm open to it, however as far as I'm aware objective c does't have any built in regex support.
Using NSScanner:
NSLog Output: