The regex that follows is working the way I want it too (at least in my tests). I'm looking for feedback on better ways to write it. In particular, is there a shortcut to repeating my 'basic component' listed below? And is there a way to make the regex more readable with line breaks that don't become part of the expression?

I'm trying to check some date input to a Web form. The formats I accept are 'mm/dd/yy, m/d/yy, mm/dd/yyyy, m/d/yyyy'.

Here's the regex I'm using to check:

( $date=~/^((\d\d?)\/(\d\d?)\/(((\d{2,2}))|(\d{4,4})))($|(,(\s*)((\d\d?)\/(\d\d?)\/(((\d{2,2}))|(\d{4,4}))))+$)/ )

Basic component is:

((\d\d?)\/(\d\d?)\/(((\d{2,2}))|(\d{4,4})))

then either end the line:

$

or go on with a comma, optional white space and repeat of the basic component and finally anchor to the final line end.

Thanks.

(Please copy [EMAIL PROTECTED] on responses as I digest. Thanks.)
--
Peter Fleck
University of Minnesota Cancer Center
[EMAIL PROTECTED]
www.cancer.umn.edu

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to