Features of Cyrillic in PHP Regular Expressions
Cyrillic characters are not included in the
\w group. To get them, you need to use
a group in square brackets, like this: [а-я].
But even with this group there is a problem - the letter
'ё' will not be included here. To include it,
you need to do this: [а-яё].
In addition, for the correct operation of Cyrillic
in regex, it is necessary to set the
u modifier:
<?php
$str = 'яяя ййй ёёё';
$res = preg_replace('#[а-яё]#u', '!', $str);
?>
Given a string:
<?php
$str = 'wйw wяw wёw wqw';
?>
Write a regular expression that will find strings
by the pattern: the edges are the letters 'w',
and between them is a Cyrillic letter.
Given a string:
<?php
$str = 'ааа ббб ёёё ззз ййй ААА БББ ЁЁЁ ЗЗЗ ЙЙЙ';
?>
Write a regular expression that will find all words by the pattern: any Cyrillic letter any number of times.