Settings

Theme

ArkRegex: A drop in replacement for new RegExp() with types

arktype.io

7 points by ssalbdivad 8 months ago · 6 comments

Reader

wredcoll 8 months ago

Sure, now make it work without having to type "\\w"

  • ssalbdivadOP 8 months ago

    Yes, there are limits on what string literals can precisely represent, but we've tried to be pragmatic about trade offs around clarity, concision and performance.

    Subexpressions like `\\w` or `[a-Z]` would just be inferred as `${string}`, but that doesn't mean the inference won't be useful. For example:

    expression: regex("^\\w+@\\w+\\.\\w+$") type: Regex<`${string}@${string}.${string}`>

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection