Python (re)

ULID in PY

Match 26-character ULIDs (Universally Unique Lexicographically Sortable Identifiers).

Try it in the PY tester →

Pattern

regexPY
\b[0-9A-HJKMNP-TV-Z]{26}\b   (flags: g)

Python (re) code

pyPython
import re

pattern = re.compile(r"\b[0-9A-HJKMNP-TV-Z]{26}\b")
input_text = "01ARZ3NDEKTSV4RRFFQ69G5FAV"
for m in pattern.finditer(input_text):
    print(m.group(0))

Stdlib `re` module — no third-party dependency. Works on Python 3.6+.

How the pattern works

ULIDs use Crockford Base32 which excludes I, L, O, U to avoid confusion. Exactly 26 characters, word-bounded.

Examples

Input

01ARZ3NDEKTSV4RRFFQ69G5FAV

Matches

  • 01ARZ3NDEKTSV4RRFFQ69G5FAV

Same pattern, other engines

← Back to ULID overview (all engines)