Regex for Comma Separated Number or Just Number

前端 未结 5 500
情歌与酒
情歌与酒 2021-01-22 08:18

This is something of a follow up from a previous question. The requirements have changed, and I\'m looking for some help with coming up with regex for either a comma separated n

5条回答
  •  清歌不尽
    2021-01-22 08:36

    Just add an "or one or more digits" to the end:

    ^(?:\d{1,3}(?:[,]\d{3})*|\d+)$
    

    I think you had it almost right the first time and just didn't match up all your parentheses correctly.

提交回复
热议问题