RE: [PHP] String validation

From: Date: Thu, 26 Oct 2000 14:31:34 +0000
Subject: RE: [PHP] String validation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22140@lists.php.net to get a copy of this message
Hi Dallas, [...] > I want to verify that the username and > password are in this format: > > 20 chars long > contain valid characters A-Z a-z 0-9 and _ > No spaces anywhere and no dashes. > > what is the expression and syntax to do this? Im not too good at > string validation. Here's a regex that would do the job: ^[[:alnum:]_]{20}$ # only matches if 20 characters long and A-Za-z0-9 or _ . ^[[:alnum:]_]{8,20}$ # does the same as the above, but string can be between 8 and 20 characters long. Cheers, Matthias

« previous php.general (#22140) next »