View Full Version : checking in between negative number with regExp
frontline
10-24-2002, 12:30 PM
as the topic syes can it be done say if i like to check
number range for example from -100 to 120
or from -20.34 to 3.345
thanks
Roy Sinclair
10-24-2002, 03:35 PM
function isInRange(testValue,minValue,maxValue)
{
if (testValue < minValue || testValue > maxValue) return false;
return true;
}
Edit: Sorry, didn't see the REGEXP until after I posted. Don't know if it can be done with a regular expression but I suspect it can.
beetle
10-24-2002, 05:31 PM
it COULD be done with a regex, but the solution is FAR more complicated than Roy's simple function. This is not a good use for regular expressions (determining value of numbers...) To give you and idea of what I mean, here is a a regular expression that validates an IP address
^(([2]{1}[0-5]{2}|[2]{1}[0-4]{1}[0-9]{1}|[1]?[0-9]{2}|[0-9]{1})[\.]){3}(([2]{1}[0-5]{2}|[2]{1}[0-4]{1}[0-9]{1}|[1]?[0-9]{2}|[0-9]{1})(\:[0-9]{1,5})?$
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.