/^[\-\.\s\'A-яA-zЁёәіңғүұқөһӘІҢҒҮҰҚӨҺ]*$/ - this regular expression for some reason skips ^\_ . How to write correctly so that it does not miss these characters?
- At least remove the point from the list - splash58
- one@ splash58 And the point does not please you, inside the list it means exactly itself - Mike
- regex101.com/r/wS6wQ1/1 Does not miss anything. What is the problem? - koks_rs
- @Mike, with slashes, this is some kind of bug. The story shows that I added them, although I don’t remember them adding them. - koks_rs
- one@Mike in! and I screen it all the time :) - splash58
2 answers
A-яA-z
А-Яа-яA-Za-z About Ёё not forgotten - it is further in the original expression.
PS: How much can you ...
- Colleague, do not you think that lately questions on
JSand similar things (like regulars) are surprisingly stupid ... easy? As if someone did not even think to look at the textbook / mana. - user207618 - @Other, I don’t know, half of me even read laziness ... It seems like yesterday there was a good question about apply. Although also simple. - Qwertiy ♦
- one@Other, the questions are not stupid. In explicit form, this is not googled. If you give a link to the manual for this occasion - honor and praise you. - VenZell
- one@VenZell, what’s the point of copying from one place to the second? Not on one site, so on the second will be. And the same MDN may well exist more SO, mana will be more whole. - user207618
- oneHere you are laughing, that the questions are stupid, and even my sieve turns out to be, because
A-zА-яwrite a lot of places on the Internet, and nobody else knows about the fact that it takes ranges in ASCII (or rather, in Unicode). notes, and he never just thought - andreymal
Updated with encoding clarifications
Consider a table of ASCII characters (taken from here ):
- works as a pointer to a range of characters.
Consider what the range of Az characters includes according to the table.
This range includes characters from 65 to 122, among which, in addition to the letters of the Latin alphabet, \ , ^ and _ are present in different registers. Just those characters that you did not plan to include in the expression, but, by negligence, included.
With Russian characters, too, everything is not so simple. In Unicode, almost all letters of the Russian alphabet in upper and lower case (except ё and Ё ) fit into the range 0410 - 044F . Ё code 0401 , and ё code 0451 .
Therefore, it is necessary to form such a range for the letters of the Russian alphabet: [а-яА-ЯЁё] . Here you did everything right.
For reference: in javascript, you can use the alternative syntax of the range for Russian letters: [\u0410-\u044f\u0401\u0451] , which is fully equivalent to [а-яА-ЯЁё] .
The conclusion here is one: you must be careful to use ranges.
In your case it is necessary to use а-яА-Яa-zA-Z . Full example:
/^[\-\.\s\'а-яА-Яa-zA-ZЁёәіңғүұқөһӘІҢҒҮҰҚӨҺ]*$/ - 2Um ... The answer doesn't fit this dosov table. For her, it should be not
А-Яа-яЁё, butА-Яа-пр-яЁёor evenА-пр-ё(that’s the one who sees such an expression). But this encoding is no longer used. At least not exactly on js. - Qwertiy ♦ - you were mistaken, not 44-101, but 65-122 - Jean-Claude
- @Qwertiy, I would not pay attention when looking for a picture with an ASCII table. Updated to current. - VenZell
- @ Jean-Claude, you're right, looked at the wrong column. Updated the answer. - VenZell
- 2ASCII contains only characters from 0 to 127 and not a character more, from 128 to 255, which in this case is already Windows-1251 - andreymal
