if (ereg('^[a-z][-a-z0-9\._]*[a-z]$', $TestPwd)) {
echo "Good";
} else {
echo "Bad password $TestPwd";
}
should do it.
If you want a case insensitive match, use eregi(...) instead. The
above regexp allows passwords as short as 2 characters. If you want
to, for example, enforce a password length of 4 to 8 characters, you
can do:
ereg('^[a-z][-a-z0-9\._]{2,6}[a-z]$', $TestPwd)
See
http://php.he.net/manual/en/function.ereg.php
for more info.
-steve
At 5:55 PM -0700 9/24/01, Oliver Ertl wrote:
>Hi,
>
>I need a regex for a username validation. The ereg
>function should be used.
>
>o the username must start and end with a-z
>o in the middle it could be a-z0-9\.-_
>o and never something like this -- -. _- and so on
>
>Thanks for your help
>
> Oliver
>
>
>
>=====
>mailto: [EMAIL PROTECTED]
>www.ertl.co.za
>
>__________________________________________________
>Do You Yahoo!?
>Get email alerts & NEW webcam video instant messaging with Yahoo!
>Messenger. http://im.yahoo.com
>
--
+------------------------ Open source questions? ------------------------+
| Steve Edberg University of California, Davis |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+----------- http://pgfsun.ucdavis.edu/open-source-tools.html -----------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]