You are not logged in.

#1 2009-02-05 06:17:05

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,222
Website

[SOLVED] Regex Not Matching Date

Can anyone enlighten me as to why the below regex in PHP doesn't match this string and set $IS_TZ to true?

2 FEB 2009

if (preg_match('^(0?[1-9]|[1-2][0-9]|3[0-1])[- /.](JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[- /.](19|20)?[0-9]{2}$', $TZ)) $IS_TZ = true;

I'm also open to better ways to validate a timestamp in PHP? wink roll

Last edited by fukawi2 (2009-02-05 21:24:42)

Offline

#2 2009-02-05 09:22:16

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: [SOLVED] Regex Not Matching Date

Hmm, am I wrong or does your regex miss the delimiters i.e:

preg_match('#[regex]#', $foo)

Offline

#3 2009-02-05 21:24:29

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,222
Website

Re: [SOLVED] Regex Not Matching Date

Obviously I'm still learning Regex... I didn't know PHP required those delimiters... It works now, thanks chimeric smile

I'll read up on those delimiters.

Offline

Board footer

Powered by FluxBB