PHP GENERAL 29 RE PHP REGULAR EXPRESSION
Date: Tue, 08 Jul 2003 10:58:29 -0700

Subject: RE: [PHP] Regular Expression
From: ralph@no-spam (Ralph Guzman)

Thanks Wendell. This is exactly what I was looking for.

-----Original Message-----
























From: Wendell Brown [mailto:wbrown@no-spam
Sent: Tuesday, July 08, 2003 4:47 AM To: PHP General Mailing List
Subject: Re: [PHP] Regular Expression

On Mon, 07 Jul 2003 21:59:23 -0700, Ralph Guzman wrote:

>I have a form where I have to check whether user is submitting a PO Box >as an address. I wrote the following using eregi, but it returns true >even when the field is not Po Box. How do I go about doing this >properly?
>
>if(eregi("^Po Box$", $address)){
> $error_message_custom = "You cannot use a PO BOX for Bill To Address";
>}

I think this would do better...

if( preg_match( "/P[\. ]*O\.* +BOX/i", $address ) )

This will look for a "P" followed by a space, period or an "O" followed by a period and/or one or more spaces and the word BOX. It will also ignore case.

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