fork(4) download
  1. <?php
  2.  
  3. $word = "'Ankara'da!?'";
  4. echo trim(preg_replace_callback('~\b\'\b(*SKIP)(*F)|\s*(\p{P}+)\s*~u', function($m) {
  5. return ' ' . preg_replace('~\X(?=\X)~u', '$0 ', $m[1]) . ' ';
  6. }, $word));
  7.  
  8.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
' Ankara'da ! ? '