Skip Navigation

Text Only/ Printer-Friendly

cleanup rule - check_against_regexp

March 3, 2006 at 1:00 pm
By nwhite

I've added a function check_against_regexp to util.php3 that allows user-supplied input to be matched (using preg_match) against one or more regular expressions.

For example, the following cleanup rule checks to make sure the user supplied id is comprised entirely of alphanumeric characters or the _ character. If the input doesn't pass the check, it becomes a NULL value.

var $cleanup_rules = array('id' => array
('function' => 'check_against_regexp',
'extra_args' => array('/^[a-z0-9_]*$/i')));

A few common regular expressions can be referenced in the extra arguments array by name. These are currently:

  • 'alphanumeric' => '/^[a-z0-9]*$/i'
  • 'email' => '/^[0-9A-Za-z_\-]+[@][0-9A-Za-z_\-]+ ([.][0-9A-Za-z]+)([.][A-Za-z]{2,3}){0,1}$/x'

Files modified

  • util.php3

Add a comment

Name:*
Comment:*
The following fields are not to be filled out. Skip to Submit Button.
Not Comment:
(This is here to trap robots. Don't put any text here.)
Not URL:
(This is here to trap robots. Don't put any text here.)
Avoid:
(This is here to trap robots. Don't put any text here.)