正则表达式匹配2位冒号2位数

时间:2022-09-27 11:13:35

I need a regex to validate data has been entered in the following format: 22:33.

我需要一个正则表达式来验证数据是否已按以下格式输入:22:33。

3 个解决方案

#1


5  

use thjis regular expression ^\d{2}:\d{2}$

使用thjis正则表达式^ \ d {2}:\ d {2} $

#2


1  

Since you don't specify any particular regex type or where it might occur in input; this is an example [0-9][0-9]:[0-9][0-9].

由于您未指定任何特定的正则表达式类型或输入中可能出现的位置;这是一个例子[0-9] [0-9]:[0-9] [0-9]。

If you want to match the whole input to just being exactly on that format ^[0-9][0-9]:[0-9][0-9]$ .. etc.

如果你想匹配整个输入只是正好在那个格式^ [0-9] [0-9]:[0-9] [0-9] $ ..等

#3


1  

^\d\d:\d\d$ should do the trick.

^ \ d \ d:\ d \ d $应该做的伎俩。

#1


5  

use thjis regular expression ^\d{2}:\d{2}$

使用thjis正则表达式^ \ d {2}:\ d {2} $

#2


1  

Since you don't specify any particular regex type or where it might occur in input; this is an example [0-9][0-9]:[0-9][0-9].

由于您未指定任何特定的正则表达式类型或输入中可能出现的位置;这是一个例子[0-9] [0-9]:[0-9] [0-9]。

If you want to match the whole input to just being exactly on that format ^[0-9][0-9]:[0-9][0-9]$ .. etc.

如果你想匹配整个输入只是正好在那个格式^ [0-9] [0-9]:[0-9] [0-9] $ ..等

#3


1  

^\d\d:\d\d$ should do the trick.

^ \ d \ d:\ d \ d $应该做的伎俩。