parsePattern

Mask
stable

Compile a mask pattern string into an array of `IMaskToken` objects. `#` matches a digit, `A` matches a letter, `*` matches any character, and all other characters become literal separators. Results are cached per pattern.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

pattern
required
string
The mask pattern string. Special characters: `#` (digit), `A` (letter), `*` (any). Every other character is treated as a literal separator (e.g. `-`, `/`, `(`, `)`).

API

Return value

The value returned by this util.

An array of token descriptors, each with `{ kind, char, consumer }`. `consumer: true` means the token consumes one character of user input; `consumer: false` means it is a literal automatically inserted.

Usage

Examples

Ready-to-paste usage snippets.

Compile a phone number mask

typescript