You are here: Regex help « HTML « IT news, forums, messages
Regex help

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация