public
Last active

leon's p.o. box detection regex

  • Download Gist
po_box_re.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// 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]));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.