* Thus wrote Ralph Guzman ([EMAIL PROTECTED]): > 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.
/p\.?o\.?\s*box/i > > 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"; > } hmm.. if i read that right that will only match #2 (I'm not sure that the [] includes a null match or not.) Also the character class [] has special escapes, you dont need to escape the period because the period is literal there. there are other alternatives people might also type like: p/o box thus my original pattern becomes: /p[.\\]?o\.?\s*box/i HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php