Re: Problem with regex

From: Date: Tue, 25 Sep 2001 07:46:59 +0000
Subject: Re: Problem with regex
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68656@lists.php.net to get a copy of this message
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: oliver@ertl.co.za 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 | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +----------- http://pgfsun.ucdavis.edu/open-source-tools.html -----------+

« previous php.general (#68656) next »