PO Box Validation

后端 未结 3 1214
别那么骄傲
别那么骄傲 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:07

    As of now with your regex, the 'O' in 'OFFICE' is required. Try ^\s*((P(OST)?.?\s*(O(FF(ICE)?))?.?\s+(B(IN|OX))?)|B(IN|OX)) instead (grouping the 'O' in a conditional match).

    EDIT: That should be /^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i instead. BTW, http://rubular.com/ is a pretty good regular expression testing engine. Always nice to know of new tools :)

提交回复
热议问题