[PHP] Form Validation: Surnames with Apostrophe

2003-03-12 Thread tpc
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 apostro

Re: [PHP] Form Validation: Surnames with Apostrophe

2003-03-12 Thread tpc
that could work but the user may now submit one or more apostrophes as the Last Name. On Wed, 12 Mar 2003, John Nichel wrote: > Try > > preg_match ( "/[A-Za-z-']+/", $_POST['Last_Name'] ); > > [EMAIL PROTECTED] wrote: > > I have been trying to validate a form field Last_Name and have been un

[PHP] PCRE regexp bug ?

2003-08-15 Thread tpc
I use preg_match to validate the Middle Initial field of a form and so far it works, except yesterday a user submitted a "0" (zero) as a middle initial! My regexp is: if (!empty($_POST[MI]) && (preg_match('/^[[:alpha:]]{1,1}$/', $_POST[MI]) == 0)) I tested it with 0-9 and my regexp catches ever

Re: [PHP] PCRE regexp bug ?

2003-08-15 Thread tpc
Thank you. I did the following: if (isset($_POST[MI]) && (preg_match('/^[[:alpha:]]{1,1}$/', $_POST[MI]) == 0)) and zero is caught. On Fri, 15 Aug 2003, CPT John W. Holmes wrote: > From: <[EMAIL PROTECTED]> > > > I use preg_match to validate the Middle Initial field of a form and so far > > i

Re: [PHP] PCRE regexp bug ?

2003-08-15 Thread tpc
I believe I spoke too soon. If I use isset() then even if I leave the field empty it still returns true. I am trying to view the documentation for this function but php.net seems to be timing out now. On Fri, 15 Aug 2003 [EMAIL PROTECTED] wrote: > > Thank you. I did the following: > > if (iss

RE: [PHP] Form Validation: Surnames with Apostrophe

2003-03-27 Thread tpc
I just tried your regexp: (preg_match("/[a-z](\\')?[a-z-]+/i",$_POST[Last_Name]) and it allows the following: O' [EMAIL PROTECTED] It seems to allow any number of characters and spaces between the O' and Re On Wed, 12 Mar 2003, John W. Holmes wrote: > > > preg_match ( "/[A-Za-z-']+/", $_POST

RE: [PHP] Form Validation: Surnames with Apostrophe

2003-03-27 Thread tpc
When I do that: (preg_match("/^[a-z](\\')?[a-z-]+$/i",$_POST[Last_Name]) it won't allow O'Reilly and seems to not allow anything at all On Thu, 27 Mar 2003, Jennifer Goodie wrote: > That is because it is not saying that is all that can be in the string. The > 'Re' matches that pattern. Put a

RE: [PHP] Form Validation: Surnames with Apostrophe

2003-03-27 Thread tpc
Thank you. Strip_slashes was the key. The following Regular Expression: (preg_match("/^[[:alpha:]]{2,}[-]?[[:alpha:]]+$|^[[:alpha:]]{2,}[[:space:]]?[[:alpha:]]+$|^[[:alpha:]]{1,1}[']?[[:alpha:]]+$/", $Last_Name) allows only alphabetical characters (e.g., Smith), alphabetical characters with wh