Hi all
I'm parsing an HTML page with CFHTTP and need to find and get a date inside
that. Do you know any regex to find a date in a string like this Date:
2007-05-03 08:11:29.0
~|
Macromedia ColdFusion MX7
Upgrade to MX7
Do you want it 'smart' or just plain?
[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]
This simply says 4 numbers followed by a dash followed by 2 numbers followed
by a dash followed by 2 numbers then a space then 2 numbers,a colon, 2
numbers, a colon, 2 numbers, a period and then a
[0-9]{4}-[0-9]{1,}-[0-9]{1,} [0-9]{1,}:[0-9]{1,}:[0-9]{1,}\.0
Is one way
-Original Message-
From: Web Specialist [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 7:52 AM
To: CF-Talk
Subject: RegEx to find a date in a string
Hi all
I'm parsing an HTML page with CFHTTP and need to
Try:
\b\d{4}-\d{2}-\d{2}\s+d{2}:\d{2}:\d{2}\.\d\b
There's no validation built-in and no intelligence, but if you just
need a basic pattern match that should do (untested). The leading and
trailing \b just make sure that the pattern is bracketed by non-word
characters and not part of some greater
By the way...
Mine allows for 1 digit months, days, hours, minutes and seconds using {1,}.
That basically says 1 or more.
-Original Message-
From: Andy Matthews [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 8:10 AM
To: CF-Talk
Subject: RE: RegEx to find a date in a string
I'd be hesitant to use {1,} as the modifier as it is totally open ended.
[0-9]{1,} will match 9, 99 and 999. If a month/date can be one or two
numbers then I can see using {1,2}. I used {2} assuming that the month/date
would always be a 2 digit number.
for those not in the know, {1} is a
Good point Michael...thanks for the clarification.
-Original Message-
From: Michael Dinowitz [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 8:24 AM
To: CF-Talk
Subject: Re: RegEx to find a date in a string
I'd be hesitant to use {1,} as the modifier as it is totally open ended.
Thanx Michael and all! ;-)
Works fine! Only one tip:
cfset findDate=ReFind([0-9]{4}-[0-9]{2}-[0-9]{2}
[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{1,3},local.datePI,1,'true')
cfset position = findDate.pos[1]
cfset length = findDate.len[1]
cfset local.datePI=Mid(local.datePI,position,length)
8 matches
Mail list logo