It is necessary to remove the newline character from the regulars list so that it does not cut. I did not find any symbol table, can anyone know what code it is behind?

preg_replace('/([^\pL\pN\pP\pS\pZ])|([\xC2\xA0])/u', ' ', $string); 

All function:

 function istrip($string) { $old_string = $string; $string = strip_tags($string); $string = preg_replace('/([^\pL\pN\pP\pS\pZ])|([\xC2\xA0])/u', ' ', $string); $string = str_replace(' ',' ', $string); $string = trim($string); if ($string === $old_string) { return $string; } else { return istrip($string); } } 

Regex

2 answers 2

In order not to cut, you need not to remove, but add the \pC symbol (connecting punctuation):

 preg_replace('/([^\pL\pN\pP\pS\pZ\pC])|([\xC2\xA0])/u', ' ', $string); 
  • Works, but displays non-printable characters as a question mark - Rammsteinik
 preg_replace('/[\x00\x80-\xFF]/', ' ', $string); 
  • Does not work with Russian characters, who should, take, leave here. - Rammsteinik