社区
C#
帖子详情
求只能输入整数的正则表达式?
cshibing
2006-08-23 09:19:01
Regex regex = new Regex("[0-9]");
这个正则表达式 不能判断111eee之类的输入,我现在要求只能输入整数
...全文
5328
12
打赏
收藏
求只能输入整数的正则表达式?
Regex regex = new Regex("[0-9]"); 这个正则表达式 不能判断111eee之类的输入,我现在要求只能输入整数
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
petshop4
2006-09-14
打赏
举报
回复
同意楼上的
正则只能匹配 不能检测输入
必须给文本框加事件才行
Nara
2006-09-14
打赏
举报
回复
同意楼上的
sswwee
2006-09-14
打赏
举报
回复
2楼的2星让人无语
sswwee
2006-09-14
打赏
举报
回复
"[0-9]"
=============
这当然不行了,你这只是匹配一个啊就说其中只要有1个数子就算匹配,而且不用[0-9]这么麻烦
0个或多个 ^\d*$
1个或多个 ^\d+$
LGame
2006-09-13
打赏
举报
回复
学习了
jin_yong
2006-08-25
打赏
举报
回复
Require : /.+/,
Email : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
Phone : /^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/,
Mobile : /^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/,
Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
IdCard : /^\d{15}(\d{2}[A-Za-z0-9])?$/,
Currency : /^\d+(\.\d+)?$/,
Number : /^\d+$/,
Zip : /^[1-9]\d{5}$/,
QQ : /^[1-9]\d{4,8}$/,
Integer : /^[-\+]?\d+$/,
Double : /^[-\+]?\d+(\.\d+)?$/,
Float: /^[-\+]?\d+(\.\d+)?$/,
Float2: /^(0|[1-9]\d{0,3})(\.\d{0,2})?$/,
English : /^[A-Za-z]+$/,
Chinese : /^[\u0391-\uFFE5]+$/,
DateTime:/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))(\s\d{1,2}:\d{1,2}:\d{1,2})?$/,
UnSafe : /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
IsSafe : function(str){return !this.UnSafe.test(str);},
SafeString : "this.IsSafe(value)",
Limit : "this.limit(value.length,getAttribute('min'), getAttribute('max'))",
LimitB : "this.limit(this.LenB(value), getAttribute('min'), getAttribute('max'))",
Date : "this.IsDate(value, getAttribute('min'), getAttribute('format'))",
Repeat : "value == document.getElementsByName(getAttribute('to'))[0].value",
Range : "getAttribute('min') < value && value < getAttribute('max')",
Compare : "this.compare(value,getAttribute('operator'),getAttribute('to'))",
Custom : "this.Exec(value, getAttribute('regexp'))",
Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))",
feesuo
2006-08-25
打赏
举报
回复
Regex regex = new Regex("^[0-9]*$");
vosov
2006-08-25
打赏
举报
回复
afhel()
汗。。。收藏
www_123du_com
2006-08-25
打赏
举报
回复
Regex regex = new Regex("^[0-9]*$");
afhel
2006-08-25
打赏
举报
回复
1
"^\d+$" //非负整数(正整数 + 0)
"^[0-9]*[1-9][0-9]*$" //正整数
"^((-\d+)|(0+))$" //非正整数(负整数 + 0)
"^-[0-9]*[1-9][0-9]*$" //负整数
"^-?\d+$" //整数
"^\d+(\.\d+)?$" //非负浮点数(正浮点数 + 0)
"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮点数
"^((-\d+(\.\d+)?)|(0+(\.0+)?))$" //非正浮点数(负浮点数 + 0)
"^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //负浮点数
"^(-?\d+)(\.\d+)?$" //浮点数
"^[A-Za-z]+$" //由26个英文字母组成的字符串
"^[A-Z]+$" //由26个英文字母的大写组成的字符串
"^[a-z]+$" //由26个英文字母的小写组成的字符串
"^[A-Za-z0-9]+$" //由数字和26个英文字母组成的字符串
"^\w+$" //由数字、26个英文字母或者下划线组成的字符串
"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" //email地址
"^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$" //url
oolongTea
2006-08-23
打赏
举报
回复
^([0-9]*)$
fengfangfang
2006-08-23
打赏
举报
回复
Regex regex = new Regex("\d{1,10}");
C#
正则表达式
文本框验证:
只能
输入
整数
和带两位小数的小数
Visual Studio 2010平台,C#语言。一个WinForm程序用以测试C#
正则表达式
文本框验证:
只能
输入
整数
和带两位小数的小数。如暂时无法下载,可以查看本人CSDN博客里相应文章中关于该程序的思路。能力有限,仅供交流学习,请多多指教。
只能
输入
正
整数
的
正则表达式
及常用的
正则表达式
主要介绍了
只能
输入
正
整数
的
正则表达式
以及常用的
正则表达式
,需要的朋友可以参考下
文本框
只能
输入
数字,小数点,减号 字符的
正则表达式
文本框
只能
输入
数字,小数点,减号 字符的
正则表达式
C#
正则表达式
小结(常用的
正则表达式
)
常用的
正则表达式
C#
正则表达式
小结 - z
只能
输入
数字:"^[0-9]*$"。
只能
输入
n位的数字:"^\d{n}$"。
只能
输入
至少n位的数字:"^\d{n,}$"。
只能
输入
m~n位的数字:。"^\d{m,n}$"
只能
输入
零和非零开头的数字:"^(0|[1-9][0-9]*)$"。
只能
输入
有两位小数的正实数:"^[0-9]+(.[0-9]{2})?$"。
只能
输入
有1~3位小数的正实数:"^[0-9]+(.[0-9]{1,3})?$"。
只能
输入
非零的正
整数
:"^\+?[1-9][0-9]*$"。
只能
输入
非零的负
整数
:"^\-[1-9][]0-9"*$。
只能
输入
长度为3的字符:"^.{3}$"。
正则表达式
大全
只能
输入
n位的数字:"^\d{n}$"。
只能
输入
至少n位的数字:"^\d{n,}$"。
只能
输入
m~n位的数字:。"^\d{m,n}$"
只能
输入
零和非零开头的数字:"^(0|[1-9][0-9]*)$"。
只能
输入
有两位小数的正实数:"^[0-9]+(.[0-9]{2})?$"。
只能
输入
有1~3位小数的正实数:"^[0-9]+(.[0-9]{1,3})?$"。
只能
输入
非零的正
整数
:"^\+?[1-9][0-9]*$"。
C#
110,534
社区成员
642,575
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章