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.
24時間のJavaScript正規表現は何ですか? そのような:
18:30
正規表現文字列を変数に割り当てて、何度も使用する必要があります。
ありがとうございました
使用する
"([01]?[0-9]|2[0-3]):[0-5][0-9]"
使用できます
^([01]\d|2[0-3]):?([0-5]\d)$
0 または 1 の後に任意の数字 (00 から 10 時間) が続くか、2 の後に 0、1、2、3 (20 から 23 時間) が続き、オプションのコロン (必要な場合は?を削除) が必要です。 0 から 5 の後に任意の数字 (分) が続きます。
?