RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find PO Box
Expression
\b[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*\.*\s*[B|b][O|o|0][X|x]\b
Description
This expression will match almost all variations of PO Box.
Matches
P.O. Box, Po Box, Post Office Box, Box, P0 Box
Non-Matches
Controller's Office
Author Rating: The rating for this expression. Chris Myers
Source Self
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Don't match stree tnames
Name: Noah Sepsenwol
Date: 8/5/2011 9:30:40 AM
Comment:
So your expression doesn't match "Box Street" or " Box Elder Lane", I look for digits at the end of the expression: \b[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*\.*\s*[B|b][O|o|0][X|x].*\d+\b to match "PO Box 234", etc.


Title: Only the world box is necessary for a match....
Name: Sean Seymour
Date: 1/5/2008 9:30:23 PM
Comment:
for instance, matches this my box why not require a number at the end? also, you're looking for 0 to infinity matches with those stars... {0,1} is a ? I suggest modifying to this \b([P|p](OST|ost)?\.?\s?[O|o|0](ffice|FFICE)?\.?\s)?([B|b][O|o|0][X|x])\s(\d+)


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials