其实
只要满足:float就可以了
我在http://www.regexplib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
查到一个:
Expression: (^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$)
Description: Accepts only positive decimal values. Zero and negatvie numbers are non-matching. Allows zeros after last non-zero numeric value after decimal place for significant digits.
Matches: [0.050], [5.0000], [5000] [ More Details]
Non-Matches: [0], [0.0], [.0]
不能验证科学记数法,如1.234+e9
只要满足:float就可以了
我在http://www.regexplib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3
查到一个:
Expression: (^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$)
Description: Accepts only positive decimal values. Zero and negatvie numbers are non-matching. Allows zeros after last non-zero numeric value after decimal place for significant digits.
Matches: [0.050], [5.0000], [5000] [ More Details]
Non-Matches: [0], [0.0], [.0]
不能验证科学记数法,如1.234+e9
解决方案 »
- js window.location.replace()问题
- 高手求解
- 求entity fromwork 增删该查代码 急急急,做毕业设计的,求大家帮忙,万分感谢
- url中空格问题
- 如何向Repeater控件的FooterTemplate内添加汇总信息?
- *紧急问题*水晶报表打印处理时如何判断打印是否完毕
- c# 怎样杀掉EXCEL 进程
- 水晶报表,求救,等待
- 請教各位高手,一個SQL問題和DataGrid 思歸 急啊。。。在線等。。
- 怎么利用cookie统计在线用户?
- c#调用javascript问题.
- 我下载的asp.net源代码里全是编译好的,根本看不到c#源代码,请各位告诉我哪里能下到完整的源代码,谢谢!
Response.Write(rg.IsMatch(TextBox1.Text));
Regex rg=new Regex(@"^(\d+(\.\d+)?|\d(\.\d+)?\+[eE]\d+)$");
Response.Write(rg.IsMatch(TextBox1.Text));
但是不能验证用科学记数法表示的数据。
zjsen(星愿)(个人观点,仅供参考.请自行验证) 的方法虽然可以验证,但是没有排除负数的情况其实我想验证的就是如下几种:
能匹配:
1235
12.035
0.025
12.00
1.234+e9
小数点后可以有不定个0
但是小数点前面若是第一位置为0,则不能多于两个0
即00.123不匹配
1.2340+e9也不能匹配。请各位大虾多多帮忙
我再加点分。
1235
12.035
0.025
12.00
1.234+e9
1.2340+E9 这也是科学记数法呀
123.0+e3 同上
00.123 多个零没关系吧,一时找不到方法不匹配的
1234. error
1234+e3 error
1234e3 error
123.e+3 error
1.234+e9+e3 error
1.234+e9e3 error
......
1,浮点数
([0-9]*\.[0-9]+)|([0-9]*)
能匹配形如:00.89 (要求不能匹配) , 但不能匹配: 1.2+e7 (要求能匹配)