What do [^(ab)]
and [^(a)]
mean?
#45
Comments
This will be a syntax error. Solution 1.5.b in #7 essentially says: "A character class can only be negated if it is guaranteed to not contain strings."
This is an interesting question that I don't think has been answered yet. Basically, are we allowed to assume that If we are allowed to assume that every single-character string is treated as a single character, then |
Thanks for the clarification 👍 Personally, I would be more surprised if |
Also, I just read through the current spec draft. The relevant section is "22.2.1.7 Static Semantics: MaybeStrings". The NonEmptyClassString case states that single-character class strings are not MaybeStrings. So |
Thanks Michael, spot on :-) Yes,
Consider that often times people may not be sure whether some "thing" is encoded using a single code point or multiple. If they are not sure, then they can use the string literal syntax.
|
Thanks everyone! I'm closing this since my questions have been answered. If anyone is interested in watching the progress in the transpiler implementation, you can check mathiasbynens/regexpu-core#51. |
I'm working on transpiler support for this proposal in regexpu-core/Babel, and I have a question about negated classes with strings. I already read #7 and I feel like it should answer my question, but I don't understand exactly how it should work.
[^(ab)]
be compiled to? Is it something like(?!ab)[^]
? Or just[^]
?[^(a)]
? Is it the same as[^a]
, or it's just[^]
?The text was updated successfully, but these errors were encountered: