Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,52 @@ In other words, the new flag would indicate several connected changes related to

For more discussion see [issue 2](https://github.com/tc39/proposal-regexp-set-notation/issues/2).

### How is the `v` flag different from the `u` flag?

The answer to this question can be useful when “upgrading” existing `u` RegExps to use `v`. Here’s an overview of the differences:

1. Previously invalid patterns making use of the new syntax (see above) now become valid, e.g.

```
[\p{ASCII_Hex_Digit}--[Ff]]
\p{RGI_Emoji}
[_\q{a|bc|def}]
```

- Some previously valid patterns are now errors, specifically those with a character class including either an unescaped [special character](https://arai-a.github.io/ecma262-compare/snapshot.html?pr=2418#prod-ClassSetSyntaxCharacter) `(` `)` `[` `]` `{` `}` `/` `-` `\` `|` or [a double punctuator](https://arai-a.github.io/ecma262-compare/snapshot.html?pr=2418#prod-ClassSetReservedDoublePunctuator):

```
[(]
[)]
[[]
[{]
[}]
[/]
[-]
[|]
[&&]
[!!]
[##]
[$$]
[%%]
[**]
[++]
[,,]
[..]
[::]
[;;]
[<<]
[==]
[>>]
[??]
[@@]
[^^]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibson042 @markusicu @macchiati @pthier Is /[^^]/v actually an error? I noticed the current V8 implementation allows it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it isn't, as the first ^ is consumed by the production CharacterClass :: [ ^ ClassContents ], so the remaining ^ is not a reserved double punctuator. [^^^] is an error in V8.
Note that also []] is not a breaking change, as this is an error also with /u.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess [_^^] or, indeed, [^^^] is a better example. I’ll change this. Thanks!

[]] is currently not listed as a breaking change, so I think there’s no action to be taken for that one. Let me know if I misunderstood.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: #74

[``]
[~~]
```

- The `u` flag suffers from confusing case-insensitive matching behavior. The `v` flag has different, improved semantics. See [issue #30](https://github.com/tc39/proposal-regexp-set-notation/issues/30) for details.

### What’s the precedent in other RegExp flavors?

Several other regex engines support some or all of the proposed extensions in some form:
Expand Down