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

-----Original Message-----
From: Wendell Brown [mailto:[EMAIL PROTECTED] 
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




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

Reply via email to