Sorry to pick holes in your first post to the list ;) but this part of your
suggested regex 

        (\w{3,})

will match any alphanumeric character (i.e it will match on the numbers or
letters in the string). By limiting it to three places, you force the match
to work. It's not good practice though.

Matching on a non-digit character will produce the same result, with more
flexibility.

So

($day, $month, $year) = $date =~ /(\d+)(\D+)(\d+)/;
                                    ^     ^    ^
                                    |     |    |
            Match one or more numbers     |    |
                                          |    |
              Match one or more NON numbers    |
                                               |
                 Match one or more numbers again

HTH

John


-----Original Message-----
From: Will Crain [mailto:[EMAIL PROTECTED]]
Sent: 03 July 2001 15:41
To: [EMAIL PROTECTED]
Subject: RE: A Split Question

-- Original Message --

>My file has dates in it that either come out as "2Jul2001" or "21Jul2001".
> So one or two digits for the day, three for the month, and four for the
>year.
>
>So I would like to split out the day, month, year, and am interested in
>splitting techniques, where there are no delimeters.
>

This is my first contribution to the list, I hope it helps.  You should
be able to extract your date data using this regex -

($day, $month, $year) = $date =~ /(\d{1,2})(\w{3,})(\d{4})/;

This assumes $date contains your date string and results in $day, $month
and $year containing the individual data bits.

Will



Visit iWon.com - the Internet's largest guaranteed cash giveaway! Click
here now for your "Thank You" gift:
http://www.iwon.com/giftcenter/0,2612,,00.html?t_id=20157




--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.


Reply via email to