-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
JavaScript regex
flavor
#2299
Comments
Thank you for the detailed suggestion! All the requirements you have listed are already supported by regex101 (some flags need to be set using However, I'm on the fence if I should (and can) support this in a meaningful way.
This looks like an amazing programmatic aid for regexes in javascript, but perhaps not super well suited as a flavor, and the implementation on the site may not do it justice. What do you think? |
Thanks for the thoughtful response, @firasdib. Those are very reasonable concerns, and of course no hard feelings if you feel that it's not the right fit. Some thoughts in response:
Perhaps something like "ECMAScript library: regex" or "Library: regex (JavaScript)". These aren't perfect, but naming flavors is also potentially tricky with other regex libraries not built into programming languages that could be supported in the future. E.g. if you ever wanted to support Rust's Another option would be to introduce a new concept of variations, libraries, packages, or similar that can be selected within particular flavor options. In this world, the flavor "ECMAScript (JavaScript)" might default to a "RegExp" suboption, but have a way to switch to "Library: regex". Then, the two existing PCRE flavor options could be collapsed the same way, potentially with the top level name "PCRE", which would default to suboption "PCRE2 (PHP >= 7.3)". This might also open the door to more easily adding support for things like Rust's
I'd imagined that regex101 would totally ignore interpolation, since that is a feature of the |
These are good ideas. I've injured my shoulder, so can't try things out right now, but I will return to this as soon as I am back in business. |
Awesome--I'll be happy to help however I can. Note: Since regex101 would need to call |
Heads up that
|
@slevithan Thank you for the update. Super exciting development happening, I'll be sure to deep dive into it in the near future. |
Just a note that regex 4.1 added support for possessive quantifiers. That completes all syntax I've wanted to add (and what I consider to be the most important features missing from JS), so I expect |
Flavor Request
I have a biased interest as the creator of the new
regex
library (which is a spiritual successor to the broadly-used XRegExp library which has been around since ES3 days), but still I think it would be significantly beneficial for JavaScript programmers, both people who are already using theregex
library and people who would discover there is a better and more readable way to write native JavaScript regexes.From its readme:
Implementation should be straightforward compared to any other new regex flavor because it's a lightweight library that runs on the client, and its features are a strict superset of native JavaScript regexes with flag
v
enabled. All of its extended features are already available in flavors that regex101 supports.Following is a complete list of the changes that would be needed to support the JavaScript
regex
flavor, compared to the existing support for the "ECMAScript (JavaScript)" flavor:u
(unicode), since flagv
is always enabled.v
(vnicode) is always enabled.x
(extended) is available and always enabled.xx
(which regex101 doesn't yet list as an option) and Java'sx
flag (which is supported by regex101, although Java allows any whitespace in character classes with flagx
).n
(non-capturing) is available and always enabled.n
in .NET (which regex101 already supports as an option) and PCRE (where regex101 doesn't yet list it as an option).(…)
should describe it as a non-capturing group, which is already supported by regex101 for the .NET flavor with flagn
enabled.\1
, etc.) as errors, since numbered backreferences to named groups are disabled by the always-on flagn
(different from .NET, but the same as Ruby and C++ with its flagn
equivalentnosubs
).n
).(?>…)
as an atomic group.(?>…)
in PCRE, Java, and .NET, where regex101 already supports atomic groups.\g<name>
as a subroutine.\g<name>
in PCRE, where regex101 already supports subroutines. Edit: The only difference is it can't be used recursively.`
.There is detailed documentation for all of these features in the
regex
package's readme, and of course I would be happy to help however I can.The text was updated successfully, but these errors were encountered: