fork(1) download
  1. <?php
  2.  
  3. $text = 'Random -text! and a japanese word アオサギ and one with many pppppss';
  4. $text1 = preg_replace('/[^\p{L} ]/u', ' ', $text) . " <= Removes diacritics" . PHP_EOL;
  5. echo $text1;
  6. $text2 = preg_replace('/[^\p{L}\p{M} ]/u', ' ', $text) . " <= Keeps diacritics" ;
  7. echo $text2;
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Random  text  and a japanese word アオサギ and one with many pppppss <= Removes diacritics
Random  text  and a japanese word アオサギ and one with many pppppss <= Keeps diacritics