Posted by BernieH on 10/10/05 13:23
I need a regex which will extract the year only from a variety of date
strings such as -
April 8, 2000
13 May 1999
April 1999
1999
20050908 (yyyymmdd format)
The year will always be either the 1st 4 or the last 4 characters of the
string.
What I have at the moment is ^([0-9]{4}).*$ for the YYYYMMDD format, but I'm
not sure how to accomodate the first 3 examples. .*[0-9]{4}$ doesn't seem to
cut it.
I don't do enough regexes to be very confident with them.
TIA for any help
bernieh
Navigation:
[Reply to this message]
|