Thanks Solomon,
What you need to add to your regex expression is boundary matchers to make sure it macthes the whole input string. Something like this^[-]?3[1-7]*[.]{0,1}[0-9]{0,6}$On Wed, Oct 26, 2011 at 10:44 AM, Kiti Chigiri <kiti.chigiri@gmail.com> wrote:
_______________________________________________Hi,
I am writing a couple of regex values to validate for valid longitude values that should fall within a specific range , and so far i got the general syntax ok
for longitudes , my regex is as follows:
[-]?3[1-7]*[.]{0,1}[0-9]{0,6}
i.e an optional negative sign followed by a number in the range 31-37 , followed by an optional decimal point, and if there is a decimal point then a set of numeric character to a max of 6 characters.
When i run the regex on some test values i get the following results
-31.00000000 TRUE
31.00000000 TRUE
-37.999999999 TRUE
37.999999999 TRUE
-36.744uiu82 TRUE ( but should be false.; it truncates the characters to return a true on -36.744)
36.744uiu82 TRUE ( but should be false.; it truncates the characters to return a true on 36.744)
-3sers6.744uiu82 TRUE ( but should be false.; it truncates the characters to return a true on -3)
3sers6.744uiu82 TRUE ( but should be false.; it truncates the characters to return a true on 3)
28.90909 FALSE (does not fall in range)
-28.90909 FALSE (does not fall in range)My problem is with the values in the text highlighted . Obviously 36.uoiuy5656 is not a valid value since in its entirety it contains a mix of non-numeric valuesWhat am i doing wrong or missing here? I am not well versed with greedy or backreferenced syntax. Any assitance would be greatly appreciated.Kind regardsKiti Chigiri
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke--
Solomon Kariri,
Software Developer,
Cell: +254736 729 450
Skype: solomonkariri
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke