PO Box Validation

后端 未结 3 1216
别那么骄傲
别那么骄傲 2021-02-15 16:44

Looking to validate PO Box but wanted to know if such validation existed. I have the Address field split into Address 1 and Address 2 (Where such PO, Apt, Suite info would go)

3条回答
  •  礼貌的吻别
    2021-02-15 17:09

    This one works better, as it removes the unneeded groups in the match set and just returns the whole match.

    Skips Post 123:

    /^\s*((?:P(?:OST)?.?\s*(?:O(?:FF(?:ICE)?)?)?.?\s*(?:B(?:IN|OX)?)+)+|(?:B(?:IN|OX)+\s+)+)\s*\d+/i
    

    Doesn't Skip Post 123:

    /^\s*((?:P(?:OST)?.?\s*(?:O(?:FF(?:ICE)?)?)?.?\s*(?:B(?:IN|OX)?)?)+|(?:B(?:IN|OX)+\s+)+)\s*\d+/i
    

    Remove the \d+ at the end to skip the number requirement.

提交回复
热议问题