Um... this doesn't use RE however it returns the date in whatever format you
want and if the date isn't valid it returns the input value... let me know
your thoughts:

<CFSCRIPT>
thisDate = "10 Jan 2asdf005";
        endDate = dateReformat('dmy','dmy',thisDate," ");
        
        function dateReformat(formatin,formatout,date) {
                thisDelimiter = "/";
                if ( Not IsDate(date) ) { return date; }
                if ( ArrayLen(arguments) EQ 4 ) { thisDelimiter =
arguments[4]; }
                if ( ListLen(date,thisDelimiter) GTE 3 ) {
                        item1 = Trim(ListGetAt(date,1,thisDelimiter));
                        item2 = Trim(ListGetAt(date,2,thisDelimiter));
                        item3 = Trim(ListGetAt(date,3,thisDelimiter));
                        }
                writeoutput(item1 & " | " & item2 & " | " & item3 & "<BR>");
                inDate = "";
                switch(formatin) {
                        case "dmy": { day = item1; month = item2; year =
item3; break; }
                        case "mdy": { day = item2; month = item1; year =
item3; break; }
                        case "ymd": { day = item3; month = item2; year =
item1; break; }
                        }
                writeoutput(day & " | " & month & " | " & year & "<BR>");
                writeoutput(outDate);
                switch(formatout) {
                        case "dmy": { outDate =
DateFormat(inDate,'dd/mm/yyyy'); }
                        case "mdy": { outDate =
DateFormat(inDate,'mm/ddyyyy'); }
                        case "ymd": { outDate =
DateFormat(inDate,'yyyy/mm/dd'); }
                        }
                return outDate;
                }
</CFSCRIPT>

You could even add the shortDateMask function from cflib to it and then you
could output based on locale... overkill I think... 

Dawesi

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur
Sent: Saturday, 14 August 2004 7:50 AM
To: CFAussie Mailing List
Subject: [cfaussie] Re: [OT] regex

Actually, you we're right I only scrolled down to (?=) if I scrolled down a
bit more I would have seen (?:)

I'll see on Monday if (:/|-) will do the trick for me.

What I'm doing is creating a function that reformats a date, i.e. from
mm/dd/yyyy to dd/mm/yyyy etc..

Taco Fleur

Tell me and I will forget
Show me and I will remember
Teach me and I will learn 


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Adam Cameron
> Sent: Friday, 13 August 2004 5:23 PM
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: [OT] regex
> 
> 
> > look ahead (?=/|-) would do that for me??
> 
> Possibly ?: not ?=
> 
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/regexp11.htm
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/regexp18.htm

Although, in the regexp your working with... what does it matter if it
captures them or not?  Given the subexpression you're using, it's always
going to match SOMETHING, or the whole regexp is going to fail, so if you
get a match at all, you know the third and fifth subexpressions returned are
going to be either a slash or a dash.  Equally, they're going to be the same
length (ie: 1), you can safely assume that fact too.  I can see no gain from
doing a look-ahead.

I think you're making your life hard for yourself.

What exactly are you trying to do (other than matching a date, that is).

Adam

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to