fork download
  1. <?php
  2.  
  3. $re = '/([^\w.])\1+/';
  4. $str = ' .....I......#### ';
  5. $subst = '$1';
  6. $result = preg_replace($re, $subst, $str);
  7. echo "The result of the substitution is '".$result . "'";
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
The result of the substitution is ' .....I......# '