Skip to content

Instantly share code, notes, and snippets.

@leeoniya
Created April 1, 2011 23:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeoniya/899034 to your computer and use it in GitHub Desktop.
Save leeoniya/899034 to your computer and use it in GitHub Desktop.
leon's p.o. box detection regex
// leon's p.o. box detection regex
// for better results, trim and compress whitespace first
var pobox_re = /^box[^a-z]|(p[-. ]?o.?[- ]?|post office )b(.|ox)/i,
arr = [
"po box",
"p.o.b.",
"p.o. box",
"po-box",
"p.o.-box",
"PO-Box",
"p.o box",
"pobox",
"p-o-box",
"p-o box",
"post office box",
"P.O. Box",
"PO Box",
"PO box",
"box 122",
"Box122",
"Box-122",
];
for (var i in arr)
console.log(pobox_re.test(arr[i]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment