24小时格式的正则表达式 [英] Regular Expression For Hours in 24 Format

查看:171
本文介绍了24小时格式的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要正则表达式
我想以以下格式在文本框中输入小时数",但从
起不超过24小时
&
00,01,02,03 ---- 24
0,1,2,3 ---- 24

没有负数或albhabet

need Regular Expression
i want enter the Hours in text box in following format but not more then 24 from

&
00,01,02,03----24
0,1,2,3----24

no negative number or albhabet

推荐答案

尝试:
\d{1,2}

数字,仅一个或两个.
如果只需要0-24,则必须分别列出它们:

Digit, one or two only.
If you want only 0-24, then you would have to list them individually:

00|01|02|0|1|2

(一直到24)

老实说,我不会单独使用正则表达式:我会将文本框内容转换为数字,然后进行检查.

(only all the way to 24)

To be honest, I wouldn''t use a regex alone: I would convert the text box content to a number, and check that.


这篇关于24小时格式的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆