Answer the question
In order to leave comments, you need to log in
How to leave only Cyrillic in a string?
Hello. I have the following problem. It is required to remove all characters from the string, except for spaces and Cyrillic. I do it like this:
$titleAttraction = "Красная площадь Red Square (Krasnaya ploshchad)";
$russianTitleAttraction = preg_replace("/[^а-я ]/", "" , $titleAttraction);
$russianTitleAttraction = trim($russianTitleAttraction);
echo $russianTitleAttraction;
Answer the question
In order to leave comments, you need to log in
The file must be encoded in Unicode UTF-8 and in the regular expression /[^a-z ]/u
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question