Hi,
Not tested this but I think it 'should work. forgive me if I have made any
goofs....

/DATE\s+[:]?\s+?(0?[1-9]|[123]\d|3[01])\/(0?[1-9]|1[120])\/(19\d\d|20\d\d|\d
\d)/

$day = $1;        # make sure days is not greater than 31
$month = $2;    # make sure months not greater than 12
$year = $3;       # check for years 19xx, 20xx or xx

Regards
Mark

----- Original Message -----
From: "Gary Luther" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 3:31 PM
Subject: Regex giving me fits!! :-(


I am having to parse dates out of lines where the date format varies
considerably.

Here is the statement that is contained in $look

  EFFECTIVE DATE:  07/12/01                        DAILY CUSTOMER ACCOUNT
REPORT                                RUN DATE:  07/13/01

There are two blanks (in this particular file in front of the EFFECTIVE.
The DATE: 07/12/01 can appear in slightly varying formats from report to
report. The possibilities are:

DATE: nn/nn/nn
DATE  nn/nn/nn
DATE : nn/nn/nn
DATE:  nn/nn/nnnn

and perhaps more that I have yet to discover. Here is the match statement I
am using to parse out the date:

$look =~ /^\s*DATE\s?\W?\s+(\d{2}\/\d{2}\/\d{2,4})/;

What I expect in $1 is 07/12/01

The \W? is for the disappearing colon (:)

I have run several programs through that have a similar structure and they
seem to work but this one fails for some reason.

So...Guru's I would appreciate your inciteful reflections and / or
incantations as to why this is not working.

TIA


--
-------------------------------------------------------------------------
"They that can give up essential liberty
   to obtain a little temporary safety
   deserve neither liberty  nor safety."

-- Benjamin Franklin
-------------------------------------------------------------------------
RRRRR                Gary Luther
RR  RR               SAF
RR  RR UTABEGAS      2500 Broadway
RR RR                Helena, MT 59602
RRRR                 [EMAIL PROTECTED]
RR RR  ULE !!
RR  RR               Visit our website at
RR   RR              http://www.safmt.org





----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to