Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在文本中输入小时:分钟示例 04:30。在按钮上单击我需要检查它是否只有数字,没有特殊字符,没有字母,特别是中间的冒号。需要一个匹配的正则表达式。请帮忙。
尝试这个:
^(([0-9])|([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9]))$
^(?:2[0-3]|[0-1]?\d):[0-5]\d$将在有或没有前导零的情况下工作。
^(?:2[0-3]|[0-1]?\d):[0-5]\d$