-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Allow for custom regex, and clarifying the usage of anyOf()
#237
Comments
Nice suggestions! I'm also thinking about simplifying a series of |
|
The main issue with custom regexp is that it bypasses the type safety of this library, which is why I've hitherto intentionally made it difficult to add custom chunks of regexp. Instead, I think it would make sense to focus on providing any missing pieces (e.g. the API to create custom character sets you mention). Ranges (meant to be implemented in #162) and greedy/non-greedy globs are two other pieces to add in, and I'd be up for thinking about more also. |
Agreed, now that I think about it, the primary use cases that I envisioned for the escape hatch were for character sets and the lazy quantifier. It is probably best to natively implement that functionality and not implement the escape hatch. Edit(04/01/2023): I removed the requirements to close this Issue and explained them below in a separate comment. |
Hi @xRSquared, @danielroe some suggestions or inputs are welcome! If everything is good, maybe we can update or add some examples in the doc? |
List of features needed to close this Issue:
|
Hi. How far are you from implementing the custom character sets? Have you considered the API for them and for negative character sets as well? I find myself using regexps like |
@didavid61202 @danielroe , As I was working on issue #7, two issues/points of clarification for the API came to mind.
Allowing for custom regex patterns
Unless there is a function that I don't know of, a user can't add to an expression using custom regex unless it is exported as one of the helpers for specific RegExp characters such as
digit
,whitespace
,letter
, etc. For example, using the current API there is no way to include the following regex pattern[1-9]
without it being passed toexactly()
and ending up as\[1-9\]
.Note: the regex pattern was passed to
exactly()
hereWhen working within the package, we can create these arbitrary regex patterns using
createInput()
; however, this function isn't exported to end users.Possible Solutions
createInput
named one of the followinginput
,rawInput
,regex
, or some other suggestionProviding an alias to
createInput
would allow for patterns such as:anyOf
@didavid61202 @danielroe, the
anyOf
function states that it takes an array of inputs, but it doesn't really take an array; it takes an arbitrary number of arguments. The function documentation stating it takes an array can lead to confusion, and in fact, it confused me when I first started using this package.Consider the following examples:
Possible Solutions
The text was updated successfully, but these errors were encountered: