/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// based on Quad_Scrub: http://code.google.com/p/quadphp/source/browse/trunk/library/Quad/Scrub.php function clean(&$val, $allowedChars = 'ascii') { 'word' => '/[^a-zA-Z\x{00C0}-\x{00FF}\x{0100}-\x{02AF}\x{1E00}-\x{1EF9}\d -\/:;=\?@\[-_\{-~ \t\.]/u', 'alpha' => '/[^a-zA-Z\x{00C0}-\x{00FF}\x{0100}-\x{02AF}\x{1E00}-\x{1EF9}]/u', 'alphanum' => '/[^a-zA-Z\x{00C0}-\x{00FF}\x{0100}-\x{02AF}\x{1E00}-\x{1EF9}\d]/u', 'id' => '/[^\w_]/', 'date' => '/[^\d :TzZ-]/', 'email' => "/[^@\w\.!#$%&'*+\-\/=?^_`{|}~]/", // http://en.wikipedia.org/wiki/E-mail_address Dec 2009 'url' => '/[^\w\._&?#+%=\/~:-]/', 'ascii' => '/[^ -~]/', ); $regex = $types[$allowedChars]; } else { $regex = $allowedChars; } return $val; }
Comments
