I have this regular expression:
@"(?i)\b(?:p(?:ost)?\.?\s*[o0](?:ffice)?\.?\s*b?(?:[o0]x)?|b[o0]x)"
Can someone help me identify the issue and correct this regex to catch the scenarios I need it to and allow others to pass?
It looks like this is catching any address that contains ‘Po’ at any point.
For example:
123 Polar Road
165 Super Point Drive
etc… would all fail.
I need it to catch:
P.O. Box 123
PO Box 123
PO 123
P0B 123
Box 123
Post Office Box 123
Looks like when I made the B optional this occurred. but I need the b to be optional to catch PO 123.
Try this:
@”(?i)\b(?:P(?:[0o]st|.?) ?0O? ?(?:B(?:.|[0o]x)?)?|B[0o]x) *([0-9]+)\b”
should catch all the examples you listed