Front page | perl.beginners |
Postings from April 2002
RE: regex
Thread Previous
|
Thread Next
From:
Bob Showalter
Date:
April 29, 2002 07:10
Subject:
RE: regex
Message ID:
2E4528861499D41199D200A0C9B15BC031B9CE@taylorwhite.com
> -----Original Message-----
> From: drieux [mailto:drieux@wetware.com]
> Sent: Sunday, April 28, 2002 11:16 AM
> To: beginners@perl.org
> 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...
Thread Previous
|
Thread Next