fork download
  1. <?php
  2.  
  3. $re = '/\\\\(\\\\)|\\\\./s';
  4. $str = 'ab\\xy ab\\\\xy ab\\\\\\xy';
  5. echo $result = preg_replace($re, '$1', $str);
  6.  
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
aby ab\xy ab\y