Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit 158b514

Browse files
Add FAQ about not-proper-subset subtraction (#36)
Issue: #32
1 parent a8862a7 commit 158b514

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,21 @@ Matching the longest strings first is key to the integration with properties of
247247
248248
For more details on the rationale for matching longest strings first, see [issue #25](https://github.com/tc39/proposal-regexp-set-notation/issues/25).
249249
250+
### How does subtraction behave in the case of `A--B` where `B` is not a proper subset of `A`?
251+
252+
As mentioned in the answer to the previous question, according to both the current ECMAScript specification and other regular expression implementations, **character classes are mathematical sets**. As such, the removal of strings that are not present in the original set is not an error, but rather a no-op. Example (note that `RGI_Emoji` includes the string `🇧🇪`, but `RGI_Emoji_ZWJ_Sequence` does not):
253+
254+
```
255+
# Proper subset.
256+
[\p{RGI_Emoji}--(🇧🇪)]
257+
# Not a proper subset.
258+
[\p{RGI_Emoji_ZWJ_Sequence}--(🇧🇪)]
259+
```
260+
261+
It would be confusing and counterproductive if one of these patterns threw an exception.
262+
263+
Several of [the real-world illustrative examples in this explainer](https://github.com/tc39/proposal-regexp-set-notation#illustrative-examples) rely on this useful `A--B` pattern, and it is crucial that we support it. [See issue #32 for more background.](https://github.com/tc39/proposal-regexp-set-notation/issues/32)
264+
250265
### What about symmetric difference?
251266
252267
We considered also proposing an operator for symmetric difference (see [issue #5](https://github.com/tc39/proposal-regexp-set-notation/issues/5)), but we did not find a good use case and wanted to keep the proposal simple.

0 commit comments

Comments
 (0)