Skip to main content

🦖 TS-Rex

Drizzle-inspired, fluent-API Regex builder for modern TypeScript. Automatically infers named capture group types, ensures stateless execution, and supports the latest ES2024 features including Unicode sets.

{ T }

Static type inference

Named captures are inferred directly from your builder chain at compile time. No type assertions, no as string, no surprises.

Stateless execution

Every .exec() call creates a fresh RegExp instance, making global-flag iteration safe and free of lastIndex bugs.

$\

Automatic escaping

.literal() and .anyOf() auto-escape special characters. You cannot accidentally inject a malformed pattern through these methods.

?

Deep optionality

Quantifiers like .optional() and .zeroOrMore() automatically mark inner capture types as string | undefined in the result.

0

Zero dependencies

Built entirely on standard TypeScript and native RegExp. Nothing extra is installed at runtime.

Immutable builder

Every method call returns a new RegexBuilder instance. You can safely branch a base pattern into multiple variations without side effects.