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

Xai*_*oft 1 c# regex

什么是匹配数字0到60的正则表达式?不允许使用负数而且没有小数.

SLa*_*aks 6

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

在C#中:

int temp;
if (int.TryParse(str, out temp) && temp >= 0 && temp <= 60)
Run Code Online (Sandbox Code Playgroud)


Row*_*haw 5

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

/([1-5]?[0-9]|60)/
Run Code Online (Sandbox Code Playgroud)

  • @Xaisoft:它们与Perl兼容. (3认同)