Description
Thoughts on using the regex library under the hood?
This would allow offering some unique/powerful features, including atomic groups and subroutines.
No worries if you think it's not the right fit. But otherwise, this could show up, for example, as:
subroutine(name)
- Or you could use your own name for it like
refSubpattern(name)
. - You could go all out and offer a way to create subroutine definition groups, and then use their patterns by reference.
- Or you could use your own name for it like
atomic(…)
atomic
could also be a boolean option forchoiceOf(…)
.
Additionally, since regex
supports possessive quantifiers (from PCRE, Perl, Java, Ruby, Python, etc.), you could easily offer them. E.g., all the quantifier functions could have their options changed to replace the greedy
property with type
(with values: 'greedy', 'lazy' (or 'nongreedy' if you prefer), and 'possessive'). You could alternatively include a new possessive
boolean option in addition to greedy
, but I wouldn't recommend that since there is no precedent in existing regex flavors for lazy+possessive quantifiers (for good reason, since this would effectively mean to just always use the lower bound of any quantifier).
With the addition of atomic groups and/or possessive quantifiers, you could rightly describe TS Regex Builder as a great way to avoid ReDoS / catastrophic backtracking.
Introducing regex
would also mean being able to improve any regexes within TS Regex Builder's source for readability, etc., and would be particularly beneficial if you start offering a library of common patterns (#73). In source, you'd get the full benefits of the regex
library including free spacing and comments, context-aware interpolation, etc.