Regex for numbers only

后端 未结 18 2286
野性不改
野性不改 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:22

    Another way: If you like to match international numbers such as Persian or Arabic, so you can use following expression:

    Regex = new Regex(@"^[\p{N}]+$");
    

    To match literal period character use:

    Regex = new Regex(@"^[\p{N}\.]+$");
    

提交回复
热议问题