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

Posted by BernieH on 10/11/05 00:05

Thank you for your help. I'm using Javascript.

> Why a variety of formats?

Unfortunately, I don't have any control over the input ... the dates are
coming in from a variety of third parties via OpenURL key-pairs. So I have
to work with what I've got. The formats that are coming in at this point are

YYYY
YYYYMMDD
MMM DD, YYYY

However, it may be that other formats will come through at some point.

> You shouldn't be trying to match any character (that applies to both
> expressions). Instead, you should be specific. The last format should only
> be matched if there are eight consecutive digits.
>
> /^(\d{4})\d{4}$/
>
> The first four should be matched by zero or more non-digit characters,
> followed by four digits that end the string.
>
> /\D*(\d{4})$/

Thank you for these suggestions; I'll give them a go.

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

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