Ask a Question related to PHP Development, Design and Development.
-
Ralph Guzman #1
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:
Address";>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 ToI 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
Ralph Guzman Guest
-
Regular Expression
Hi, I am writing a script that parses an html file (which has been retrieved as a scalar by LWP::UserAgent). The script looks for everything in... -
Regular expression help
Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract... -
Regular expression for both first and last name?
I'm new to regular expressions, can someone explain to me how I can write one that will check for 2 names, at least, for a name field? Thanks!... -
help on regular expression
Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)... -
[PHP] REGULAR EXPRESSION HELP
John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:... -
Paul Chvostek #2
Re: [PHP] Regular Expression
On Tue, Jul 08, 2003 at 06:47:26AM -0500, Wendell Brown wrote:
Unless preg_match does something non-standard, you don't need to escape>
> I think this would do better...
>
> if( preg_match( "/P[\. ]*O\.* +BOX/i", $address ) )
a period that's inside square brackets. In fact, the regexp you've
built will also match an $address of "p\o box".
--
Paul Chvostek <paul@it.ca>
it.canada [url]http://www.it.ca/[/url]
Free PHP web hosting! [url]http://www.it.ca/web/[/url]
Paul Chvostek Guest



Reply With Quote

