RE: [PHP] Regular Expression

This is a discussion on RE: [PHP] Regular Expression within the PHP General forums, part of the PHP Programming Forums category; Thanks Wendell. This is exactly what I was looking for. -----Original Message----- From: Wendell Brown [mailto:wbrown@arkie.net] Sent: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-08-2003
Ralph Guzman
 
Posts: n/a
Default RE: [PHP] Regular Expression

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

-----Original Message-----
From: Wendell Brown [mailto:wbrown@arkie.net]
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



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0