This question already has an answer here:
I have a contact form that is translated in both English and Russian. My client wants to be able to type Russian characters into the form fields as well as English. I am not great at regex and am hoping someone can help me adjust the regex I'm using to allow for the extra character set. I've already tried several different options I've found on here and none of them seem to be working. Which most likely means I'm not using it correctly. I'm using PHP and this is the regex for the first form input.
'/^[a-z][a-z ]*$/i'
I've tried it like this:
'/^[a-z][a-z ][\x{0410}-\x{042F}]*$/i'
'/^[a-z][a-z ][А-Яа-яЁё]*$/i'
'/^[a-z][a-z ][\p{Cyrillic}]*$/i'
But none of them seem to work.
</div>
Maybe because you didn't put them in the same bracket?
(and the other question mentions the u
flag)
'/^[a-z][a-z А-Яа-яЁё]*$/iu'