How to extract coordinates (deg,min,sec) from a string?

Hey there.

I have this data in which the “Long-Lat” column consists of a string of coordinates in degrees, minutes and seconds. I need to extract just the numbers/values of these coordinates for analysis. Is there any way of doing so?

Sample: [Long 29° 13’ 36.8 E Lat 25° 51’ 21 S ]


I think given the number of figures you want to capture, using RegEx would be an option. I’m not a RegEx master, but here’s a pattern I got to work with your sample data:


You can this as the “Pattern” in the Regex Split node and it will put your degrees, minutes, seconds, and direction all in separate cells and then you can recombine them depending on what you want to do next.


This is amazing.! Thanks a lot. I really have to ask, how did you manage to come up with the RegEx pattern for this problem?


Glad it’s working for you! I used to work through it. It’s a nice site to input your target data and try different Regex patterns until you find one that works. It also has lots of documentation on what each of the tokens mean, so it’s helpful to learn!

1 Like


So I tried the above pattern in the splitter but it couldn’t split some of the data. Attaching sample data and a picture below of the same.

[Long 29° 15’ 50.4 E Lat 25° 53’ 5.4 S ]
[Long 29° 15’ 50.5 E Lat 25° 53’ 6.5 S ]
[Long 29° 15’ 50.2 E Lat 25° 53’ 7.6 S ]
[Long 29° 15’ 50.8 E Lat 25° 53’ 8.3 S ]


Try this one:

The missing values have extra decimal point or had a single digit for before the decimal place and the pattern wasn’t matching. The tough part of Regex is if the entire string doesn’t match the pattern nothing will work. :man_shrugging:


This one worked just fine! All the rows got split perfectly.! Thank you so much for the help…!



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.