I found a very handy thing on the Internet, but it says that such characters as ",.?\" Cannot be entered as they are character attributes. How to write a code so that it would ignore (not delete) all the letters of the alphabet, numbers and symbols ",./?!" ?

What is:

 $name = preg_replace("/[^а-яa-zA-ZА-Я0-9\s]+/u","",$string); 

    2 answers 2

    You need to escape /, and you can list the remaining characters in square brackets without a screen. So, for example:

     $name = preg_replace('/[^\d\s\/.,!?a-zа-яё]/iu','', $string); 
    • What does \d mean? I see that non-digital character, but what is it? - Telion
    • \d is the equivalent of 0-9 - A. Voronyansky

    Required to escape these characters

      preg_replace("/[^а-яa-zA-ZА-Я0-9\,\.\/\?\!\s]+/u","",$string); 

    Special symbols