regex to match number comma number

后端 未结 3 1061
有刺的猬
有刺的猬 2021-01-20 16:46

This is what I have right now:

^[0-9]([,][0-9])?$

My problem is that i want to be able add more than one digit before and after my comma. <

3条回答
  •  情书的邮戳
    2021-01-20 17:40

    I'd suggest the following:

    /^\d+,\d+$/
    

    The + 'matches the preceding item one or more times.'

    References:

    • JavaScriptRegular Expressions,at Mozilla Developer Network.

提交回复
热议问题