MB34
MB34

Reputation: 4404

POBox address capture

/^\s*((p(ost)?.?\s*(o(ff(ice)?)?)?.?\s+(b(in|ox))?)|b(in|ox))/i

Is the above the best regex to capture Post Office Box addresses?

Using the above, it failed on the ones marked below:

P.O. Box 123
PO 123
Post Office Box 123
P.O 123
Box 123
#123       // This one
123        // This one
POB 123
P.O.B 123  // This one
P.O.B. 123 // This one
Post 123
Post Box 123

Any more you can think of?

Upvotes: 1

Views: 336

Answers (1)

Nick Q.
Nick Q.

Reputation: 3986

RegexLib.com has a pretty good list of a number of different expressions you can use.

Upvotes: 1

Related Questions