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.
我的正则表达式匹配以下类型的格式化时间字符串:
12:30 12:30 AM 12:30 pm 1:30 1:30 AM
((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5 ][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)
我想知道如何修改表达式以要求am/pm?任何人都可以伸出援助之手吗?
谢谢!
删除最后一个“?”:
((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5 ][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM)))