Regular Expression

From: Date: Tue, 01 Jul 2003 13:38:58 +0000
Subject: Regular Expression
Groups: php.general 
Request: Send a blank email to php-general+get-153546@lists.php.net to get a copy of this message
Hi Everyone, I am currently using this piece of code to validate wether or not an address has only letters, numbers, #, or - in it: if (!ereg("^[A-Za-z0-9 #-]{1,20}", $_POST["address1"])) { $error = 1; $msg .= "Address must only contain letters, numbers, #, or -.<br>"; } However, if I put any valid character as the first, and then any illegal characters (!@$%, etc) after that, it passes it as ok. Can someone tell me what I am doing wrong with the regex? -Dan Joseph

« previous php.general (#153546) next »