JavaScript / ECMAScript

ULID in JS

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

Try it in the JS tester →

Pattern

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

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\b[0-9A-HJKMNP-TV-Z]{26}\\b", "g");
const input = "01ARZ3NDEKTSV4RRFFQ69G5FAV";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

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)