RE: [Phplib-users] Invalid Regex
Brought to you by:
nhruby,
richardarcher
|
From: Rob H. <rob...@ws...> - 2002-10-31 18:57:10
|
This will match 123$abc. It should fail if there are any other characters
besides alphanumeric.
> -----Original Message-----
> From: Matt Williams [mailto:li...@ye...]
> Sent: Thursday, October 31, 2002 1:36 PM
> To: rob...@ws...; Phplib-Users
> Subject: Re: [Phplib-users] Invalid Regex
>
>
> On Thursday 31 October 2002 18:32, Rob Hutton wrote:
>
> > I am trying to validate the username field, and just to make up some
> > arbitrary rules, it has to be between 6 and 25 characters long
> and have no
> > punctuation. So my valid regex looks something like
> "[A-Za-z0-9]{6,}" but
> > how do I tell it to fail if is has anything else? Like invalid_regex =
> > "[^A-Za-z0-9]"?
>
> Hi Rob
>
> to check for alphanumeric chars between 6 and 25 chars use
>
> "^[a-zA-Z0-9]{6,25}$"
>
> This will bail if it's not like that.
>
> You can drop A-Z bit depending on whether you're using ereg or eregi
>
> matt
>
>
|