Skip to content

Instantly share code, notes, and snippets.

@avocadoslab
Created March 17, 2016 21:21
Show Gist options
  • Save avocadoslab/68d778526214072815d3 to your computer and use it in GitHub Desktop.
Save avocadoslab/68d778526214072815d3 to your computer and use it in GitHub Desktop.
Regex for detecting variations on PO Box
var pobReg = /\bbox(?:\b$|([\s|\-]+)?[0-9]+)|(p[\-\.\s]?o.?[\-\s]?|post office\s)b(\.|ox)?/igm;
/*
Matches:
po box
p.o.b.
pob
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
Does not match:
123 Boxing Street
34 Box Handler Road
424 PO Dance drive
234 P.O.D. Wasn't terrible Circle
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment