Re: Form Validation: Surnames with Apostrophe
| From: | tpc at csua dot berkeley dot edu | Date: | Wed, 12 Mar 2003 22:22:40 +0000 |
| Subject: | Re: Form Validation: Surnames with Apostrophe | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139403@lists.php.net to get a copy of this message | ||
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'] );
>
> tpc@csua.berkeley.edu wrote:
> > 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?
> >
> >
> >
> >
>
>
>