Re: Regular Expression

From: Date: Tue, 05 Aug 2003 20:00:01 +0000
Subject: Re: Regular Expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-158345@lists.php.net to get a copy of this message
On Tuesday 05 August 2003 04:19, Ralph Guzman wrote: > Been working on this one for a while but can't get it working properly. > I need a regular expression to match if address is > > 1. PO Box > 2. P.O. Box > 3. P.O.Box > > I'm using /i to make this case insensitive. > > I got it working with 1 & 2, but it's still not matching 3. Any > suggestions? > > if(preg_match( "/p[\.]o\.* +box/i", trim($_POST['address'])){ > echo "Address is P.O. BOX"; > } Try: "/p\.?o\.?( )?box/i" -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Age before beauty; and pearls before swine. -- Dorothy Parker */

« previous php.general (#158345) next »