正则表达式数字小于82(Regex digits smaller then 82)

编程入门 行业动态 更新时间:2024-10-27 09:47:28
正则表达式数字小于82(Regex digits smaller then 82)

我试图写一个简单的正则表达式,但我不知道为什么它不起作用。

用户输入2位数字,如01 ,直到82 。 82系统会拒绝。

这是我的正则表达式,2位数字必须小于82。

0[1-9]|[1-8][0-9]|8[0-2]

I'm trying to write a simple regex but I don't know why it is not working.

User enter 2 digits number like 01, 09, 23, 55, until 82. After 82 system will refuse.

Here is my regex, 2 digits must be smaller than 82.

0[1-9]|[1-8][0-9]|8[0-2]

最满意答案

你应该有[1-7]范围10-79,而不是[1-8] 。 不要忘记^和$来指定字符串的开始和结束:

^(0[1-9]|[1-7]\d|8[0-2])$

You should have [1-7] for the range 10-79, not [1-8]. Don't forget the ^ and $ to specify the start and ending of the string:

^(0[1-9]|[1-7]\d|8[0-2])$

更多推荐

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

发布评论

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

>www.elefans.com

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