fork(11) download
  1. <?php
  2.  
  3. $subject = "+-&&||!( ){ } [ ]^\"~*?:/";
  4. $result = preg_replace('%([+\-&|!(){}[\]^"~*?:/]+)%', '\\\\$1', $subject);
  5. echo "Result 1: ". $result ."\n";
  6.  
  7.  
  8. $subject = "+-&&||!( ){ } [ ]^\"~*?:/";
  9. $result = preg_replace('%[^\w]+)%', '\\\\$1', $subject);
  10. echo "Result 2: ". $result ."\n";
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
Result 1: \+-&&||!( \){ \} \[ \]^"~*?:/
Result 2: 
stderr
PHP Warning:  preg_replace(): Compilation failed: unmatched parentheses at offset 6 in /home/7Ncv4E/prog.php on line 9