11
3

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.

UUIDをヒットさせる正規表現

Last updated at Posted at 2022-07-08

概要

  • UUIDをヒットさせるための正規表現をメモ的に記載しておく。

UUIDのフォーマット

  • UUIDのフォーマットは下記である。

    XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
    
  • -で区切られ8桁-4桁-4桁-4桁-12桁の0~9とa~fの英数字で表現される。

ヒットさせる正規表現

  • 下記のようになる

    ([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})
    
  • 3フィールド目の最初の一文字がUUIDのバージョンを指定しているのでUUIDのバージョンを指定してヒットさせたい場合下記のようになる。

    バージョン 正規表現
    指定なし ([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})
    1 ([0-9a-f]{8})-([0-9a-f]{4})-(1[0-9a-f]{3})-([0-9a-f]{4})-([0-9a-f]{12})
    2 ([0-9a-f]{8})-([0-9a-f]{4})-(2[0-9a-f]{3})-([0-9a-f]{4})-([0-9a-f]{12})
    3 ([0-9a-f]{8})-([0-9a-f]{4})-(3[0-9a-f]{3})-([0-9a-f]{4})-([0-9a-f]{12})
    4 ([0-9a-f]{8})-([0-9a-f]{4})-(4[0-9a-f]{3})-([0-9a-f]{4})-([0-9a-f]{12})
    5 ([0-9a-f]{8})-([0-9a-f]{4})-(5[0-9a-f]{3})-([0-9a-f]{4})-([0-9a-f]{12})
11
3
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
11
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?