regex for numbers comma and space

前端 未结 3 862
日久生厌
日久生厌 2021-01-24 08:01

I have a text area and a user can input US zip codes in it separated by a comma or (comma and space).

It could be like 12345,45678, 89654

The following regex i

3条回答
  •  执笔经年
    2021-01-24 08:12

    Use this regex: ^\d{5}(, ?\d{5})*$

    It specifies 5 digits at the beginning: ^\d{5} and any number of other comma, space, and 5 digit combinations: (, ?\d{5})*

提交回复
热议问题