普通EX pression匹配的数字不仅没有从零开始 [英] Regular expression to match numbers only not starting with zero

查看:164
本文介绍了普通EX pression匹配的数字不仅没有从零开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有窗体上的文本框,我希望用户能够只输入数字,第一个数字不能为零。其中模式必须是在这种情况下?

I have a textbox on the form and I want the user to be able to enter only numbers, and first number can not be zero. Which pattern must be in this case?

推荐答案

使用这种EX pression

Use this expression

string expression = @"^[1-9]\d*$";


对于任何想要测试前pression,使用此链接: http://www.rubular.com/r / 1JIPP8E1zH

这篇关于普通EX pression匹配的数字不仅没有从零开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆