From: Craig Kim Date: 2006-04-29T08:29:58+09:00 Subject: Re: Date-building regexes Here's what you can do: mydate = '2/4/2006' match = /\b(0?[1-9]|1[012])[- \/.](0?[1-9]|[12][0-9]|3[01])[- \/.](19|20)?[0-9]{2}\b/.match(mydate) On Wed, 26 Apr 2006, Robert Klemme wrote: > 2006/4/26, Ashley Moran : >> Hi >> >> Does anyone know of a regular expression for *building* a date? That is one >> that will match "3", "30", "30/", "30/0" (etc), but not "30/099" or >> (ideally) "30/02"? I've had a quick look into it and it seems pretty >> complex, and I figured someone must have solved the problem before. > > Not 100% sure but it might be more efficient to just implement the > automata that matches the pattern and feed events (i.e. chars) to it > while the user enters them. Otherwise your regexp will grow pretty > complex as you have to provide options / alternatives for every > possible path the pattern can take. HTH > > Kind regards > > robert > > > -- > Have a look: http://www.flickr.com/photos/fussel-foto/ > > > > --Craig Kim Octo Performance Engineering, Inc