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 (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
> > > 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 every digit except 0.
> > Curious...
> >
> > empty("0") is going to be true. So, !empty("0") is going to be false, so you
> > won't "catch" the zero.
> >
> > ---John Holmes...
> >
> >
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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
> > 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 every digit except 0.
> Curious...
>
> empty("0") is going to be true. So, !empty("0") is going to be false, so you
> won't "catch" the zero.
>
> ---John Holmes...
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[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 every digit except 0.  Curious...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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 whitespace then more alphabetical characters (e.g., Au Yong),
alphabetical character with apostrophe then more alphabetical characters
(e.g., O'Neal), or alphabetical characters with hyphen then more
alphabetical characters (e.g., Zeta-Jones).  It does not, however, allow
alphabetical character with apostrophe then more alphabetical characters
then hyphen then more alphabetical characters (D'Agostino-Wong),
alphabetical characters with whitespace then more alphabetical characters
then hyphen then more alphabetical characters (e.g., von Hollander-Smith),
or alphabetical characters with whitespace then more alphabetical
characters then hyphen then alphabetical character then apostrophe then more
alphabetical characters (e.g, Van Horn-O'Reilly) or anything else anyone
may type in or not type in.

On Thu, 27 Mar 2003, Jennifer Goodie wrote:

> This is what I use
> $LastName = stripslashes($_POST['LastName']);
> preg_match("/^\w+[\s\-\'\.\w]*$/i", $LastName)
>
> This is less strict than yours as I'm allowing whitespace, periods,
> underscores, hyphens, apostrophes, and numbers because I don't so much care
> if someone tacks on " Jr." or something like that to the end of their name.
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 27, 2003 3:05 PM
> To: Jennifer Goodie
> Cc: John W. Holmes; 'John Nichel'; [EMAIL PROTECTED]
> Subject: RE: [PHP] Form Validation: Surnames with Apostrophe
>
>
>
> 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 ^ at the beginning to signify it must
> > start with the pattern and a $ at the end to signify it must end there.
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, March 27, 2003 1:19 PM
> > To: John W. Holmes
> > Cc: 'John Nichel'; [EMAIL PROTECTED]
> > Subject: RE: [PHP] Form Validation: Surnames with Apostrophe
> >
> >
> >
> > 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['Last_Name'] );
> > > > >
> > > > > [EMAIL PROTECTED] 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?
> > > > that could work but the user may now submit one or more apostrophes
> > > > as the Last Name.
> > >
> > > Watch out for magic_quotes. If "O'Reilly" is submitted, unless you
> > > stripslash() it, you're validating against "O\'Relly".
> > >
> > > preg_match("/[a-z](\\')?[a-z-]+/i",$_POST['Last_Name'])
> > >
> > > ---John W. Holmes...
> > >
> > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> > > today. http://www.phparch.com/
> > >
> > >
> > >
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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 ^ at the beginning to signify it must
> start with the pattern and a $ at the end to signify it must end there.
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 27, 2003 1:19 PM
> To: John W. Holmes
> Cc: 'John Nichel'; [EMAIL PROTECTED]
> Subject: RE: [PHP] Form Validation: Surnames with Apostrophe
>
>
>
> 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['Last_Name'] );
> > > >
> > > > [EMAIL PROTECTED] 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?
> > > that could work but the user may now submit one or more apostrophes
> > > as the Last Name.
> >
> > Watch out for magic_quotes. If "O'Reilly" is submitted, unless you
> > stripslash() it, you're validating against "O\'Relly".
> >
> > preg_match("/[a-z](\\')?[a-z-]+/i",$_POST['Last_Name'])
> >
> > ---John W. Holmes...
> >
> > PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> > today. http://www.phparch.com/
> >
> >
> >
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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['Last_Name'] );
> > >
> > > [EMAIL PROTECTED] 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?
> > that could work but the user may now submit one or more apostrophes
> > as the Last Name.
>
> Watch out for magic_quotes. If "O'Reilly" is submitted, unless you
> stripslash() it, you're validating against "O\'Relly".
>
> preg_match("/[a-z](\\')?[a-z-]+/i",$_POST['Last_Name'])
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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 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?
> >
> >
> >
> >
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[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 apostrophe:
[\\'] and [\\\'] to no avail. Any idea what I am doing wrong?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php