> -----Original Message-----
> From: Gabby Dizon [mailto:[EMAIL PROTECTED]]
> Subject: regex help
> 
> hello list friends,

Hello.
> 
> hope you can help me with my problem. here it is:
> 
> i have a date string formatted this way:  $date = "Apr. 02, 2002"
> i want to capture the "Apr" (without the period) into $1, 
> "02" into $2, and "2002" into $3.
> note that some months may not be abbreviated (such as May), 
> and therefore might not have a period.
> my regex skills are still sadly inferior (though i'm learning =)

  $date =~ /(\w+)\.? (\d+), (\d+)/;

Bear in mind that this solution assumes that the format is always the same
(meaning exactly one space between each value you want to store.  Also be
aware that $1, $2, $3, etc. are read-only variables, so it would (probably)
be better to assign the values to another variable right away.

  my ($Month, $Date, $Year) = $date =~ /(\w+)\.? (\d+), (\d+)/;

> 
> my second (and optional) problem for you to solve: i want to 
> transform this
> into mysql date format (yyyy-mm-dd). this is easy enough to 
> do, but i was
> wondering if there are any modules there that can date 
> manipulation a lot
> easier. if you know any, just let me know.
> 
> thanks a lot!
> 
> Gabby Dizon
> Web Developer
> Inq7 Interactive, Inc.

Your best option is to check CPAN for date manipulation modules.

Hope this helps...
Jason


CONFIDENTIALITY NOTICE:

************************************************************************

The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.

************************************************************************

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

Reply via email to