Re: matching date



joez311@xxxxxxxxx wrote:
Hi,
Can someone help me out with the following pattern match? I want to
match on the date went its formated like mm/dd/yy. I was trying:
/[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
but my match doesn't seam to work as expected. I think its because of
the / used to split the feilds. Could some one show me the correct way
to pattern match on this?

Hmmm. Very hard to know exactly what you want without a real Perl code
example (please read the posting guidelines for this group). Perhaps you
want something like:

my ($month, $day, $year) = ($date_string =~
m|([01][0-9])/([0-3][0-9])/([0-9][0-9])|); # Untested. Assumes there
will always be two characters per field

Note that you can use delimiters other than '/' for your regular
expression if you start with 'm' explicity.

There are also several powerful modules on CPAN for parsing dates and
times. It would be a good idea to use one of those for any serious work.


DS
.