RegEx编号[

编程入门 行业动态 更新时间:2024-10-14 06:20:54
RegEx编号[-99.99 ..- 0.01] + [0.01..99.99](RegEx number [-99.99..-0.01]+[0.01..99.99])

我想验证一个数字。 此数字必须为-99.99至+99.99,但0(零)除外。 我想出了这个RegEx表达式

[-+]?((\d{1,2}\.?\d{0,1}[1-9])|(\d{0,1}[1-9]))

但它不处理这种类型的数量:

x0 xy.00

任何想法?

编辑:我正在尝试对xsd文件进行限制。

I want to validate a number. This number must be from -99.99 to +99.99 but except 0 (zero). I came up with this RegEx expression

[-+]?((\d{1,2}\.?\d{0,1}[1-9])|(\d{0,1}[1-9]))

but it does not handle number of this type:

x0 xy.00

Any idea?

Edit: I am trying to do a restriction for xsd file.

最满意答案

尝试:

[+-]?([1-9]\d?(\.\d\d?)?|0\.[1-9]\d?||0\.0[1-9])

含义:

[+-]? # optional '+' or '-' ( # [1-9]\d?(\.\d\d?)? # 1 - 99.99 | # OR 0\.[1-9]\d? # 0.1 - 0.99 | # OR 0\.0[1-9] # 0.01 - 0.09 ) #

Try:

[+-]?([1-9]\d?(\.\d\d?)?|0\.[1-9]\d?||0\.0[1-9])

meaning:

[+-]? # optional '+' or '-' ( # [1-9]\d?(\.\d\d?)? # 1 - 99.99 | # OR 0\.[1-9]\d? # 0.1 - 0.99 | # OR 0\.0[1-9] # 0.01 - 0.09 ) #

更多推荐

本文发布于:2023-07-30 17:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1338872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编号   RegEx

发布评论

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

>www.elefans.com

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