Adding regex for only Cyrillic letters and white spaces
To validate a string only consisting of Cyrillic letters and whitespace chars you may use
/^[\u0400-\u0484\u0487-\u052F\u1C80-\u1C88\u1D2B\u1D78\u2DE0-\u2DFF\uA640-\uA69F\uFE2E\uFE2F\s]*$/
Details
-
^
- start of string -
[\u0400-\u0484\u0487-\u052F\u1C80-\u1C88\u1D2B\u1D78\u2DE0-\u2DFF\uA640-\uA69F\uFE2E\uFE2F\s]*
- 0 or more Cyrillic letters or whitespaces (see the chars included here) -
$
- end of string.
JS test:
var s = "Меня зовут Витя";
var cyrillicValidationRegex = /^[\u0400-\u0484\u0487-\u052F\u1C80-\u1C88\u1D2B\u1D78\u2DE0-\u2DFF\uA640-\uA69F\uFE2E\uFE2F\s]*$/;
console.log(cyrillicValidationRegex.test(s));
And with the ECMAScript 2018+ compliant regex, you can shorten the pattern to /^[\p{Script=Cyrl}\s]*$/u
:
const s = "Меня зовут Витя";
const cyrillicValidationRegex = /^[\p{Script=Cyrl}\s]*$/u;
console.log(cyrillicValidationRegex.test(s));