> -----Original Message-----
> From: drieux [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, April 28, 2002 11:16 AM
> To: [EMAIL PROTECTED]
> Subject: Re: regex
> 
> 
> 
> On Sunday, April 28, 2002, at 07:13 , Mat Harrison wrote:
> 
> > what sort of regex's should i be looking at to validate a 
> username and
> > password field so that input can only be up to and 
> including 15 chars long
> > and does not contain any special characters?
> 
> you want to limit usernames and passwd's to
> 
>       [a-zA-Z0-9]
> 
> without any of the non-alphanumeric tokens....
> 
> { not a good passwd strategy if I may kvetch }
> 
> my $MAXWORD = 15;
> my $pattern = qr/^\w{1,$MAXWORD}$/;

That matches both "foobar\n" and "foo_bar", which would
seem to be "illegal" values.

Perhaps the POSIX character class would be useful:

   /^[[:alnum:]]{1,15}\z/

Matches the alphabetic character set in the current locale...


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

Reply via email to