[Tutor] regex newbie question

Steve Willoughby steve at alchemy.com
Thu May 8 22:30:39 CEST 2008


On Thu, May 8, 2008 12:40, Dick Moores wrote:
> At 11:46 AM 5/8/2008, Steve Willoughby wrote:
>>Be aware that \d{2,4} matches 2, 3 or 4 digits, which may be
>>different than what you're looking for, since 1/12/234 would
>>match
>
> Yes, I wanted to permit that. In my script, mxDateTime turns 1/12/234
> into 01/12/0234. So if a user wants to enter it, I'll let him.
>
> But here's a chance to ask: What regex would match 2-digit strings
> and 4-digit strings only?

^\d\d(\d\d)?$

> And another: What regex matches the "" string?

^$





More information about the Tutor mailing list