fork(3) download
  1. <?php
  2.  
  3. $s = " Ł ę d \r\n Я ёb ";
  4. $n = preg_replace('~(*ANYCRLF)^\h+|\h+$|(\h){2,}~um', '$1', $s);
  5. echo $n;
  6.  
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Ł ę d
Я ёb