Published on Friday, October 23rd, 2009 at 9:31 am

Below are regex patterns to match against valid latitude and longitude.

Both formats are based on Decimal coordinates.

Latitude range is from -90 to +90

Longitude from -180 to +180

For Latitude the regex pattern is

(-?[0-8]?[0-9](\.\d*)?)|-?90(\.[0]*)?

For Longitude use

(-?([1]?[0-7][1-9]|[1-9]?[0-9])?(\.\d*)?)|-?180(\.[0]*)?

This will also restrict the decimal values being > 0 for both +- 90′ and +- 180

Be Sociable, Share!

Related Posts

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


About Me

Welcome to my blog. Here you'll find mainly work related content, a suppository for all my notes which otherwise would end up on a post it note.