note 29883 added to function.preg-match

From: Date: Thu, 27 Feb 2003 15:04:14 +0000
Subject: note 29883 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-44614@lists.php.net to get a copy of this message
Harvey Allen's Textarea validation: For starters, you can use ^ to prefix a list of allowed characters, and in the event there's a single one that does not fall into this list your condition will be triggered: if (preg_match("/[^A-z0-9_\-]/", $the_text)==1) { /*ERROR*/} else { /*okie dokie*/ } You may also find useful to start your "if" statement like this: if ($the_text!=addslashes($the_text) || preg_match("/[^A-z0-9_\-]/", $the_text)==1) ...that will mean the user entered slashes, backslashes and general weird stuff that otherwise will probably zark-off your script before it gets a chance to evaluate the regexp. -- http://www.php.net/manual/en/function.preg-match.php http://master.php.net/manage/user-notes.php?action=edit+29883 http://master.php.net/manage/user-notes.php?action=delete+29883 http://master.php.net/manage/user-notes.php?action=reject+29883

« previous php.notes (#44614) next »