Re:ArkRegex: A drop in replacement for new RegExp() with types
by wredcoll on Tuesday October 28, 2025 @12:29PM
(#45735002)
Sure, now make it work without having to type "\\w"
[ Parent
| on HN ]
Re:ArkRegex: A drop in replacement for new RegExp() with types
by ssalbdivad on Tuesday October 28, 2025 @01:01PM
(#45735508)
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}`>
Re:ArkRegex: A drop in replacement for new RegExp() with types
by wredcoll on Tuesday October 28, 2025 @03:32PM
(#45737841)
Can't you use tagged literals to do something similar?
Re:ArkRegex: A drop in replacement for new RegExp() with types
by ssalbdivad on Tuesday October 28, 2025 @05:08PM
(#45739216)
Not sure exactly what you mean by "something similar".