Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
\b(((?:(P(?:ost(?:al)?)?)[ ./\-_]*(O(?:ff(?:ice)?)?)?[ ./\-_]*(b(?:o?x|in)?))|(?:(P(?:ost(?:al)?)?)[ ./\-_]*(O(?:ff(?:ice)?)?)[ ./\-_]*(b(?:o?x|in)?)?)|(?:(?<!(r(?:ural)?[ ./\-_]*r(?:oute)?)[ ./\-_]*((n\.?(?:o|um(?:ber)?)?\.?)?[ ./\-_]*#*[ ./\-_]*(\d+))?[ ./\-_]*)(box|bin)))[ ./\-_]*((n\.?(?:o|um(?:ber)?)?\.?)?[ ./\-_]*#*[ ./\-_]*(\d+)))\b
/
gmi
Input 1
1
New
const matches = [ "BIN 12", "BOX 12", "Box 12", "Box-12", "Box12", "P O Box123", "P. O. Box 13", "P.O 123", "P.O Box 12", "P.O. Box 123", "P.O. Box 123", "P.O.B 123", "P.O.B. 123", "P.o box 12", "PO 123", "PO Box 1", "PO Box 123", "PO Box N 12", "PO Box No 12", "PO Box No. 12", "PO Box Number 12", "PO Box #12", "PO Box # 12", "PO-Box 12", "PO. Box 12", "POB 12", "POB 123", "POB1", "POBOX123", "Po Box 12", "Post Box #123", "Post Box 123", "Post Office Box 123", "Postal Box 12", "box #1", "box #123", "box # 123", "box 123", "p box 12", "p o box 12", "p o box num 12", "p off b 12", "p off box 12", "p office b 12", "p office box 12", "p-o box 12", "p-o-b-1", "p-o-box-12", "p.o.bin 12", "p.o box 12", "p.o. box 12", "p.o. box. 12", "p.o.-box12", "p.o.b.#123", "p.o.b.12", "p/o box 123", "p/o-box 12", "pb 12", "po #123", "po 12", "po bin 123", "po box 123", "po box no #23", "po box no 123", "po box n.o. 12", "po box num 12", "po box num #123", "po box number #12", "po box number 12", "po bx 12", "po n 12", "po num123", "po-box-12", "pob #12", "pob num12", "pob number12", "pobox123", "post o. b. 12", "post o box 123", "post o bx 12", "post off b 12", "post off. box 12", "post office b 12", "post office box 123", "postal box 123", "postal office box 12", "postal-off-box 12", ]; const nonMatches = [ // Don't match unit numbers "B1", "#1", "# 1", "N1", "Number 1", "Num 1", "No 1", // Rural route addresses "RR 12 Box 1020", "RR Box 12", "RR #12 Box 12", "r.r. 12 box 12", "Rural Route 12 Box 12", "Rural Route # 12 Box 12", "Rural Route Box 12", "rural-route 12 box 12", // Other street addresses "1223 P Street #1", "123 ABox #1", // Respect word boundary "123 Box, #1", // This would match, but the comma prevents it "123 Bx #1", // Must use the full word "box" when by itself "123 Expo #1", "123 Harpo Box Street #1", "123 Poblano Lane #1", "123 Poor Box Road #1", "123 Some Street", "123 box canyon rd", "2 Expo Blvd #1", "34 PO Road #1", "777 Post Oak Blvd", "Army Post 1", "Box Hill", "Controller's Office", "Office 123", "Post 123", "Postal 123", "Post Office Road 123", // "Road" before the number prevents this from matching "Post Rd. #1", "Postal Road #1", "The Postal Road", "pollo St.", ];
Substitution
const matches = [ "BIN 12", "BOX 12", "Box 12", "Box-12", "Box12", "P O Box123", "P. O. Box 13", "P.O 123", "P.O Box 12", "P.O. Box 123", "P.O. Box 123", "P.O.B 123", "P.O.B. 123", "P.o box 12", "PO 123", "PO Box 1", "PO Box 123", "PO Box N 12", "PO Box No 12", "PO Box No. 12", "PO Box Number 12", "PO Box #12", "PO Box # 12", "PO-Box 12", "PO. Box 12", "POB 12", "POB 123", "POB1", "POBOX123", "Po Box 12", "Post Box #123", "Post Box 123", "Post Office Box 123", "Postal Box 12", "box #1", "box #123", "box # 123", "box 123", "p box 12", "p o box 12", "p o box num 12", "p off b 12", "p off box 12", "p office b 12", "p office box 12", "p-o box 12", "p-o-b-1", "p-o-box-12", "p.o.bin 12", "p.o box 12", "p.o. box 12", "p.o. box. 12", "p.o.-box12", "p.o.b.#123", "p.o.b.12", "p/o box 123", "p/o-box 12", "pb 12", "po #123", "po 12", "po bin 123", "po box 123", "po box no #23", "po box no 123", "po box n.o. 12", "po box num 12", "po box num #123", "po box number #12", "po box number 12", "po bx 12", "po n 12", "po num123", "po-box-12", "pob #12", "pob num12", "pob number12", "pobox123", "post o. b. 12", "post o box 123", "post o bx 12", "post off b 12", "post off. box 12", "post office b 12", "post office box 123", "postal box 123", "postal office box 12", "postal-off-box 12", ]; const nonMatches = [ // Don't match unit numbers "B1", "#1", "# 1", "N1", "Number 1", "Num 1", "No 1", // Rural route addresses "RR 12 Box 1020", "RR Box 12", "RR #12 Box 12", "r.r. 12 box 12", "Rural Route 12 Box 12", "Rural Route # 12 Box 12", "Rural Route Box 12", "rural-route 12 box 12", // Other street addresses "1223 P Street #1", "123 ABox #1", // Respect word boundary "123 Box, #1", // This would match, but the comma prevents it "123 Bx #1", // Must use the full word "box" when by itself "123 Expo #1", "123 Harpo Box Street #1", "123 Poblano Lane #1", "123 Poor Box Road #1", "123 Some Street", "123 box canyon rd", "2 Expo Blvd #1", "34 PO Road #1", "777 Post Oak Blvd", "Army Post 1", "Box Hill", "Controller's Office", "Office 123", "Post 123", "Postal 123", "Post Office Road 123", // "Road" before the number prevents this from matching "Post Rd. #1", "Postal Road #1", "The Postal Road", "pollo St.", ];