-
Notifications
You must be signed in to change notification settings - Fork 4
[Feature]. Missing Constructor #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
enhancement
New feature or request
Comments
Swift Regex Builder uses
Alternatively, we've might allow for nesting
|
I see the benefit of both solutions, but I only need the regex() api for
the URL pattern.
Thank you,
Paul
…On Tue, Mar 26, 2024 at 6:26 PM Maciej Jastrzebski ***@***.***> wrote:
Swift Regex Builder uses Regex(...) for that, so adapting it analogously
to TS Regex Builder that would be:
const port = regex([portSeperator, portNumber]);
Alternatively, we've might allow for nesting RegexSequences as elements
of RegexSequences (as arrays), so that for encoding, they would be
flattened.
const urlAuthority: RegexSequence = [optional([userInfo, at]), choiceOf(hostname), optional(port)];
export const UrlAuthorityValidator = buildRegExp(
[startOfString, urlAuthority, endOfString], // <-- Nested array happens here
{
ignoreCase: true,
},
);
—
Reply to this email directly, view it on GitHub
<#74 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BA6V6ZTQ56RH4K67EKHPZWDY2HRX7AVCNFSM6AAAAABFHXART2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGU3TKMRQGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Resolved by #77 |
Resolved in v1.4.0 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
When building complex RegExes, I often need to do something like:
OR
Then, I want to use those components in a builder:
This causes the following type error:
Type '(Repeat | Optional)[]' is not assignable to type 'RegexElement'.ts(2345)
To get around this I use a constructor [
capture(hostname) or choiceOf(hostname)
]. This works but is ugly.Describe the solution you'd like
I'd like to see a constructor (combine?, compose?, noop?, group?, ...) that groups the elements into a RegexSequence.
Describe alternatives you've considered
It turns out that this is the use case I had for non-capture groups. Even this is ugly.
Checklist
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: