Skip to content

[Feature] Use library regex to offer extended features #97

Closed as not planned
@slevithan

Description

@slevithan

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.
  • atomic(…)
    • atomic could also be a boolean option for choiceOf(…).

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions