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.
1〜999の整数、または00:00〜59:59の時間MM:SSを処理できる正規表現が必要です。これは私の試みでした^?((\d{1,3})|((([0-9])|([0-5][0-9])):(([0-9])|([0-5][0-9]))))$
^?((\d{1,3})|((([0-9])|([0-5][0-9])):(([0-9])|([0-5][0-9]))))$
それを試してください:
(([0-5][0-9]:[0-5][0-9])|\d{1,3})
(または、0:17 または 17:2 または 3:8 のようなものも一致させる必要がある場合):
((([0-5][0-9]|[0-9]):([0-5][0-9])|[0-9])|\d{1,3})
正規表現を照合するときは、左から右に文字を消費する非常に「単純な」パーサーを作成していることに注意する必要があります。