Page 1 of 1
Regular Expression, searching for a date
Posted: Sun May 18, 2003 6:13 pm
by Templeton Peck
$test= eregi('April[12-20]2003',$date);
if $date is a date in this format: May 12 2003
how can I specify a range of dates like April [12-20] 2003 to match with it? I can't figure out how to get the spaces in, because right now its trying to match April122003 for example against the $date. I don't even know if i'm doing the range of numbers right.
Any assistance would be appreciated
Posted: Sun May 18, 2003 6:48 pm
by m3mn0n
>= 12 || <= 30
greater than or equal to 12 and less than or equal to 30
Posted: Sun May 18, 2003 7:27 pm
by Templeton Peck
what about the spaces? how do I use it in an search expression
$test= eregi('April[12-20]2003',$date);
is what I have currently
Posted: Sun May 18, 2003 8:14 pm
by Templeton Peck
To be entirely accurate what i'm trying to do is match a date which is in a variable called $date and is in this format : March 12 2003 (no comma's or anything just spaces)
a bunch of dates are passed to $date from a file and I want to know how to search a range of dates to match those dates
like March[12-20] 2003 is a range I could search against the dates from file and get a match for the one example date I gave above.
eregi('April+[11-21]+2003','$date'; is what I have but it doesn't work with or without plus signs, so how can I search the range April[11-23]2003 against the $date variable and get a match if April 11 2003 was the date in the $date file
thanks

Posted: Mon May 19, 2003 3:10 am
by Tubbietoeter
try ereg and test $reg if it is in the range yoou wnat.
see php.net for the function.
as far as i know you can't to this directly within the expression, as you can only determin the kind of values not the range in the regexp
also see:
http://www.phpbuilder.com/columns/dario19990616.php3