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
What specific section or headline is this issue about?
The "try it" example.
What information was incorrect, unhelpful, or incomplete?
The example uses new RegExp('\u{61}', 'u') with and without the 'u' flag to demonstrate the difference. But '\u{61}' immediately gets converted to 'a' (and becomes the value of the RegExp source property) as part of normal string literal interpretation before the string is passed to RegExp, so the 'u' flag has no effect.
What did you expect to see?
To introduce an effect, the example would need to be rewritten to use one of the following syntaxes:
new RegExp('\\u{61}', 'u') (note: 2 backslashes instead of 1)
/\u{61}/u
Furthermore, to make the effect of the flag clear, it is not enough to show the value of the source property. The result of a match needs to be shown, e.g.:
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode
What specific section or headline is this issue about?
The "try it" example.
What information was incorrect, unhelpful, or incomplete?
The example uses
new RegExp('\u{61}', 'u')
with and without the'u'
flag to demonstrate the difference. But'\u{61}'
immediately gets converted to'a'
(and becomes the value of the RegExpsource
property) as part of normal string literal interpretation before the string is passed to RegExp, so the'u'
flag has no effect.What did you expect to see?
To introduce an effect, the example would need to be rewritten to use one of the following syntaxes:
new RegExp('\\u{61}', 'u')
(note: 2 backslashes instead of 1)/\u{61}/u
Furthermore, to make the effect of the flag clear, it is not enough to show the value of the
source
property. The result of a match needs to be shown, e.g.:Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/javascript/reference/global_objects/regexp/unicode
The text was updated successfully, but these errors were encountered: