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
[Back to original message]
|