-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(regular_expression): Update example to support RegExp construct…
…or (#5106) - Fix example to handle `new RegExp()` too - Update NOTE comments - - - Until I tried interacting with the actual AST parsed by `oxc_parser`, I thought that the current `oxc_regular_expression` lacked support for the `RegExp` constructor due to escape sequences. This was because `"\""` remained `"\""` after reading the source text from `.js` files. However, once it was parsed by `oxc_parser`, I found that everything was [resolved](https://github.com/oxc-project/oxc/blob/8ef85a43c019a1ce9aa50b61ec4dbb5dbaeb3b7b/crates/oxc_parser/src/lexer/string.rs)! (Wonderful work as usual. 👏🏻 ) Now there is nothing to worry about. 😌
- Loading branch information
Showing
3 changed files
with
86 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
const re1 = /abc{1}/gsv; | ||
const re2 = new RegExp("ooo", "u"); | ||
const re3 = /[\w--[v]]/gsv; | ||
// All of them should be the same result! | ||
[ | ||
/\1(.)\\"'`a/v, | ||
new RegExp("\\1(.)\\\\\"'`\a","v"), | ||
new RegExp('\\1(.)\\\\"\'`\a','v'), | ||
new RegExp(`\\1(.)\\\\"'\`\a`,`v`), | ||
] |
This file contains 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