允许小数和整数的正则表达式

编程入门 行业动态 更新时间:2024-10-28 12:22:49
本文介绍了允许小数和整数的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我需要编写一个正则表达式,该表达式允许使用这样的数字 1.23 和 1 进入文本框.小数点不是强制. 欢迎任何建议或链接.. !!

Hello everyone, I need to write a regular expression which will allow numbers like 1.23 and 1 in to the text-box. Decimal point is not the compulsion. Any suggestion or links are welcome..!!

推荐答案

正则表达式为: ^ [0-9] \ d {0,9}(\. \ d {1,3})?%? Regular Expression is : ^[0-9]\d{0,9}(\.\d{1,3})?%?

[0-9]:用于允许从0到9的整数的整数 d {0,9}:最多需要10位数字 \. :十进制 d {1,3}:十进制最多三位数字
[0-9] : for integers which allows integers from 0 to 9 d{0,9}: this will take up to 10 digits \. : for decimal d{1,3} : for decimal up to three digits

范围为1-9的数字,后跟零个或多个其他数字: A digit in the range 1-9 followed by zero or more other digits: ^[1-9]\d*

更多推荐

允许小数和整数的正则表达式

本文发布于:2023-11-10 23:05:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小数   整数   正则表达式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!