Prompt a regular expression. You must remove all characters except:

az AZ . ' - 

    1 answer 1

    Like that:

     $str = "AaBb ..'. - русский текст, 123456"; $str = preg_replace("/[^a-z'-.]/i", '', $str); echo $str; 

    Conclusion:

    AaBb ..'.-

    If you need spaces, add a space in brackets.

    • one
      Если нужны будут пробелы, добавьте \s в скобки. - bad advice for GAPS. - Visman
    • @Visman, cause of harm? - And
    • one
      Read what is included in the \s space characters. - Visman pm
    • @Visman, I agree, for the space, it is better to use the space. - Corrected the answer. - And