This question has already been answered:

Help create a regular calendar that deletes everything except Russian, Latin letters and numbers, and also leave spaces ... For example, this one does it as it should, but removes spaces: $result = preg_replace('/[^a-zа-яё]+/iu', '', $text);

Reported as a duplicate by members of Visman , Alexey Shtanko , Athari , Cerbo , Regent 17 Oct '15 at 12:04 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

     $result = preg_replace('/[^a-zа-яё\s0-9]+/iu', '', $text); // Где \s - это пробел, 0-9 - это цифры или $result = preg_replace('/[^\w\d\s]+/iu','',$text); 

    Check

    • Your regular season does not take the numbers, in my opinion. - LEQADA
    • Your regular season, it seems to me, will break down on that line #3# . Namely, the second # he will not rake. - LEQADA
    • Great. But could you explain why this thing works without the global modifier g ? - LEQADA
    • @LEQADA preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] ) - if limit not specified or equals -1, then all occurrences of the pattern will be replaced. Information - Alex