-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regex 'v' mode case insensitive matching says characters are folded to lower case, which is incorrect? #37466
Comments
Yes this is kind of surprising, but Unicode-aware case mapping folds everything to lowercase. If you check https://unicode.org/Public/UCD/latest/ucd/CaseFolding.txt, you see that, for example, the first line
Yeah that does make the example kind of confusing. The problem is that Welcoming two note blocks to these two pages making these clarifications! |
Thanks @Josh-Cena so IIUC with /[a-z\p{Uppercase_Letter}]/vi if the input was
|
or actually it's more like every code point in So then for /[^a\P{Lowercase_Letter}]/vi this essentially becomes a mix of "not whereas /[^a\P{Lowercase_Letter}]/ui becomes a mix of "not Hence why /[^a\P{Lowercase_Letter}]/ui.test('b') === false /[^a\P{Lowercase_Letter}]/vi.test('b') === true ? |
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class
What specific section or headline is this issue about?
Complement classes and case-insensitive matching
What information was incorrect, unhelpful, or incomplete?
What did you expect to see?
I thought it would be folded to upper case, as the linked page says
and https://tc39.es/ecma262/multipage/text-processing.html#sec-runtime-semantics-canonicalize-ch says
Do you have any supporting links, references, or citations?
Do you have anything more you want to share?
Also confused by the example. I think it implies that
/[^A-Z]/vi
should matcha
, but it doesn't?/[^A-Z]/vi.test('a') === false
MDN metadata
Page report details
en-us/web/javascript/reference/regular_expressions/character_class
The text was updated successfully, but these errors were encountered: