You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the \\u{...} example might be a bit pointless because you can just write \u{...} which is understood uses a JavaScript escape sequence and therefore works regardless of whether the u flag is used or not (I assume).1
A more interesting example might be to match a Unicode property, and / or to show that matching emojis (respectively in general any supplementary character) only works correctly when using the u flag.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
Footnotes
This also highlights a bug with the current example; the \u{61} is (if I understand it correctly) a normal JavaScript escape, so the current example is equivalent to:
const regex1 = new RegExp('a');
const regex2 = new RegExp('a', 'u');
It looks like this is your first issue. Welcome! 👋 One of the project maintainers will be with you as soon as possible. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.
\u{61} would be a string literal escape sequence; \\u{61} is the string literal form of /\u{61}/, which is actually a regex syntax of Unicode escape, which only works in u mode.
Ideally, we would have a separate page for the u flag (as part of #22210), but I'm probably not going to do that in the end, so it makes sense to make the unicode example a bit more useful.
What information was incorrect, unhelpful, or incomplete?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode
The current example just shows how to access the property, it does not show at all what effect the Regex flag has.
What did you expect to see?
The example should show what difference the
u
flag has, at the very least something like:However, the
\\u{...}
example might be a bit pointless because you can just write\u{...}
which is understood uses a JavaScript escape sequence and therefore works regardless of whether theu
flag is used or not (I assume).1A more interesting example might be to match a Unicode property, and / or to show that matching emojis (respectively in general any supplementary character) only works correctly when using the
u
flag.Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
Footnotes
This also highlights a bug with the current example; the
↩\u{61}
is (if I understand it correctly) a normal JavaScript escape, so the current example is equivalent to:The text was updated successfully, but these errors were encountered: