Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #854
Change
Regex+ by Steven Levithan is now behind the engines of
-E:rr(the default, alsodefault)uorvflag unless-u, and the extended syntax of Regex+ on top: atomic groups(?>…), possessive quantifiers likea++, and subroutines\g<name>with(?(DEFINE)…). Only the transforms of Regex+ run, not its flags.regex+v(alsoregex+andV)vflag, free spacing (x), and only named groups capture (n).regex+u(alsoU)uflag.runtimeV8,JSC$1in the replacement, in--jscode and in--output-matchstill counts only the groups of the user. The status report with--verbosetells the engine and the added groups.--literalgives the text as it is with every engine, also with the free spacing ofregex+.RE2placeholder is gone.For the release note of v8
Every piece of extended syntax was an error in the native engines, except
\g<name>. So a pattern that works today gives the same regex withrr. The one change:\g<name>was the textg<name>, and withrrit calls the group.-E runtime,-E V8and-E JSCkeep the old meaning.The copy of Regex+
regex6.1.0 andregex-utilities2.3.0 are copied intosrc/libs, with their MIT licenses. The build bundles them, so there is no new runtime dependency. The bundle grows from 52 KB to 88 KB. Biome leaves the folder alone, so it stays easy to compare with upstream. The changes from upstream, listed insrc/libs/README.md:regex-utilitiesare relative, as the build leaves bare imports out of the bundle.internals.jsexportssubroutines. Asked for upstream.rewrite()also giveshiddenCaptures, so the added groups can be skipped withoutRegExpSubclass, which makes.replace()3 to 5 times slower.When upstream exports
subroutines, the copy goes andregexbecomes a normal dependency. The README insrc/libshas the steps.Tests
test/fix/854.test.jsis new, with 49 tests, and 47 fail without the change:rrgives the same regex as the native engine for 24 legacy patterns, like\",a],\01,[a++]and[(?>].rrreads atomic groups, possessive quantifiers, subroutines andDEFINE, anddefaultisrr.$1,$2$1,$3(stays text),$10,--jsand--output-match.JSCandruntimeread\g<d>as text.regex+and its other names have free spacing and only named groups capture.regex+uusesuand notv.regex+stops the run on\", and--literalwithregex+findsa b #c (d)as it is.The tests that named
defaultas the engine of the runtime sayrrnow, andtest/cli/run.shshows an atomic group and-E runtimeon Node and Bun.yarn test-cipasses.