title: "preg_match(): Compilation failed: unmatched parentheses" in PHP for valid pattern
body: <p>Wondering if anyone out there can shed some light on why the following regular expression is failing when used in PHP's preg_match function:-</p>
  
  <pre><code>&lt;?php
  $str = '\tmp\phpDC1C.tmp';
  
  preg_match('|\\tmp\\([A-Za-z0-9]+)|', $str, $matches);
  
  print_r($matches);
  ?&gt;
  </code></pre>
  
  <p>This results in the error message "preg_match(): Compilation failed: unmatched parentheses" despite the fact that the pattern appears to be valid. I've tested it with an online <a href="http://www.pagecolumn.com/tool/pregtest.htm" rel="noreferrer">PHP Regular Expression tester</a> and the Linux tool Kiki. Seems like PHP is escaping the opening parenthesis rather than the backslash.</p>
  
  <p>I've got round the issue by using str_replace to swap the backslashes for forward ones. This works for my situation but it would be nice to know why this regular expression is failing.</p>