Form Validation: Surnames with Apostrophe

From: Date: Wed, 12 Mar 2003 20:41:10 +0000
Subject: Form Validation: Surnames with Apostrophe
Groups: php.general 
Request: Send a blank email to php-general+get-139389@lists.php.net to get a copy of this message
I have been trying to validate a form field Last_Name and have been unable to find a regexp to account for the apostrophe (e.g., O'Reilly). The following statement: preg_match('/^[[:alpha:]]+[-]?[[:alpha:]]+$/', $_POST[Last_Name]) accepts hyphenated surnames and I have tried escaping the apostrophe: [\\'] and [\\\'] to no avail. Any idea what I am doing wrong?

« previous php.general (#139389) next »