简体   繁体   English

在正则表达式中匹配0到60

[英]Match 0 to 60 in regular expression

What is the regular expression to match the numbers 0 through 60? 匹配数字0到60的正则表达式是什么? No negative numbers allowed and no decimals. 不允许使用负数,也不能使用小数。

Like this: ^([0-5]?[0-9]|60)$ 像这样: ^([0-5]?[0-9]|60)$

In C#: 在C#中:

int temp;
if (int.TryParse(str, out temp) && temp >= 0 && temp <= 60)

假设Perl兼容正则表达式,并且没有前导零

/([1-5]?[0-9]|60)/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM