1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Googleスプレッドシート】時間の入力チェックを正規表現を使用して行う

Posted at

概要

Googleスプレッドシート上で、以下のように時間(hh:mm形式)を入力し、適切か判定を行いたい場合の対応メモです。

対応方針

他にも良い方法があるかもしれませんが、以下方針で対応してみました。

  • REGEXMATCH関数を使用して、正規表現を使用して判定を行います。
  • 時間の正規表現は日付および時刻の正規表現を参考にして設定します。
  • 入力するセルの表示形式は、自動でなくテキストに設定します。(自動だと文字列として見なされないようなので)

実装サンプル

以下の関数を入力チェックのセルに設定しました。

=REGEXMATCH(C36, "^([01][0-9]|2[0-3]):[0-5][0-9]$")
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?