Regex for numbers only

后端 未结 18 2650
野性不改
野性不改 2020-11-22 03:29

I haven\'t used regular expressions at all, so I\'m having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the

18条回答
  •  佛祖请我去吃肉
    2020-11-22 04:16

    It is matching because it is finding "a match" not a match of the full string. You can fix this by changing your regexp to specifically look for the beginning and end of the string.

    ^\d+$
    

提交回复
热议问题