firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.2k stars 198 forks source link

JavaScript `regex` flavor #2299

Open slevithan opened 1 week ago

slevithan commented 1 week ago

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 the regex library and people who would discover there is a better and more readable way to write native JavaScript regexes.

From its readme:

regex creates readable, high performance, native JavaScript regular expressions with advanced features and best practices built-in. It's lightweight (6.5 KB minified and brotlied) and supports all ES2024+ regex functionality.

Highlights include support for free spacing and comments, atomic groups via (?>…) which can help you avoid ReDoS, subroutines via \g<name> which enable powerful composition, and context-aware interpolation of RegExp instances, escaped strings, and partial patterns.

With the regex package, JavaScript steps up as one of the best regex flavors alongside PCRE and Perl, and maybe surpassing C++, Java, .NET, and Python.

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:

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.