It's working here!!
Aziz,,,
#!/usr/bin/perl -w
for $look(<DATA>){
$look =~ /^\s*DATE\s?\W?\s+(\d{2}\/\d{2}\/\d{2,4})/;
print ++$i . " $1\n";
}
__DATA__
DATE: 12/12/12
DATE 12/12/12
DATE : 12/12/12
DATE: 12/12/1212
In article <[EMAIL PROTECTED]>, "Gary Luther" <[EMAIL PROTECTED]>
wrote:
> 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]