fl00d
08-08-2008, 05:51 AM
I'm trying to check if a date matches a pattern (DD/MM/YY) using preg_match and I can't figure out the damn proper pattern. I've read all over about modifiers and the delimiters and I still can't get it to work.
My pattern so far...
$datePattern = "^[0-9]{2}\/[0-9]{2}\/([0-9]{2}$"; //Format DD/MM/YY
Seems like it should be extremely simple but I could never wrap my head around regular expressions, thus why I try to avoid them as much as possible. I thought {2} was supposed to determine how long the string is allowed to be but according to PCRE manual it means
{n} Match exactly n times.
Frustrating :/
Can someone help me out?
Edit-
I tried some grouping w/() but still couldn't get it to work. Grr... I have no idea
My pattern so far...
$datePattern = "^[0-9]{2}\/[0-9]{2}\/([0-9]{2}$"; //Format DD/MM/YY
Seems like it should be extremely simple but I could never wrap my head around regular expressions, thus why I try to avoid them as much as possible. I thought {2} was supposed to determine how long the string is allowed to be but according to PCRE manual it means
{n} Match exactly n times.
Frustrating :/
Can someone help me out?
Edit-
I tried some grouping w/() but still couldn't get it to work. Grr... I have no idea