RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Longitude as decimal
Expression
^-?((([1]?[0-7][0-9]|[1-9]?[0-9])\.{1}\d{1,6}$)|[1]?[1-8][0]\.{1}0{1,6}$)
Description
Matches a longitude in the range of -180 to 180 degrees, with between 1 and 6 trailing decimal places.
Matches
-180.0 180.0 -179.010293 1.123456 -45.012 0.12
Non-Matches
180 -180 180.1 -180.1 0.1234567 190.1
Author Rating: The rating for this expression. Nick Floersch
Source Some guy named AdRock at PHPFreaks.com inspired this code
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Good stuff.
Name: Don Gillespie
Date: 9/7/2009 10:15:42 PM
Comment:
Good stuff. Tested it extensively with Firefox regex tester. Some GPS readings come out with "W 82.884833" instead of just a decimal. That's easy to test for: ^(E\s?|W\s?|-)?((([1]?[0-7][0-9]|[1-9]?[0-9])\.{1}\d{1,6}$)|[1]?[1-8][0]\.{1}0{1,6}$)


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials