开发者

RegEx Valip ZIP Code?

i need a regEx in whic开发者_运维百科h 4 or 5 digits are okay (for german, austrian or switzerland ZIP).

Please help


^\d{4,5}$

However, this gives you no guarantee whether they really exist.


A simple one would be (assuming Perl compatible regular expressions)

^(\d{4,5})$

You would still want to validate that it is an actual valid value afterwards (for example, you don't say whether leading zeroes are valid)


This will match valid Swiss or German Postal Codes (Swiss are from 1000 - 9999, German from 00000 - 99999):

^(?:[1-9]\d{3}|\d{5})$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜