typed-regex
typed-regex copied to clipboard
A typescript library for type-safe regex for named capture groups
WIP. Will need to re-write the parser to work better with nested groups without nesting the types to its limits
Current: ```ts const regex = TypedRegEx("^\w+(@(?[a-z0-9-_.]+))?$", "gi"); const captures = regex.captures(...); // { version: string } | undefined; ``` Expected: ```ts const regex = TypedRegEx("^\w+(@(?[a-z0-9-_.]+))?$", "gi"); const captures = regex.captures(...);...
Description: If a named capture group has some optional grouping itself then the whole group is optional. Test case: Current: ```ts const regex = TypedRegEx("^(?((@\\w[-\\w]*\\/)?\\w[-\\w]*))$", "gi"); const captures = regex.captures(...)...