regex allow only numbers or empty string

后端 未结 6 565
失恋的感觉
失恋的感觉 2021-02-05 04:30

Can someone help me create this regex. I need it to check to see if the string is either entirely whitespace(empty) or if it only contains positive whole numbers. If anything el

6条回答
  •  旧时难觅i
    2021-02-05 05:00

    ^\d+([\.\,][0]{2})?$
    

    I found this worked for me. Allow any whole number, but only a decimal of .00

    Pass

    • 999 90
    • 100
    • 100.00
    • 101.00
    • 1000.00

    Fails

    • 101.01
    • 1000.99

    Try it at http://regexpal.com/

提交回复
热议问题