Created
June 27, 2016 21:11
-
-
Save uri/45d41a49cf77f356a11eac36373ba0ab to your computer and use it in GitHub Desktop.
PO Box (Post office box) regular expression in ruby.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
po_box_regex = /\A\b(?:p[.\s]?o?[.\s]?b?[.\s]?)\b(?:box)?|post{1}\s(?:office)?\s?(:?box|bin){1}\z/i | |
# Matches | |
# | |
# P. O. Box | |
# P.O.Box | |
# Post Box | |
# Post Office Box | |
# P.O.B | |
# P.O.B. | |
# POB | |
# Post Office Bin | |
# P O Box DesMoines1000 | |
# P O Box Des Moines 1000 | |
# Post Office Box | |
# Post Box | |
# PO | |
# P.O. | |
# P.B. | |
# Does NOT match | |
# | |
# Post Office | |
# Bin | |
# Box | |
# 12 Box | |
# Post | |
# Postal Code | |
# Portsmouth | |
# Campbell | |
# Raspberry | |
# Polonium | |
# Polar beer. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it will fail when
Po Shau Centre, Kwun Tong, Hong Kong