title: Regular expression: Unknown modifier '\'
body: <p>I'm having the following regular expression:</p>
  
  <pre><code>(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:'\".,&lt;&gt;?«»“”‘’]))
  </code></pre>
  
  <p>but it's giving me the following error:</p>
  
  <pre><code>Unknown modifier '\'
  </code></pre>
  
  <p>I tried escaping the backslashes like this:</p>
  
  <pre><code>(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()&lt;&gt;]+|\\(([^\\s()&lt;&gt;]+|(\\([^\\s()&lt;&gt;]+\\)))*\\))+(?:\\(([^\\s()&lt;&gt;]+|(\\([^\\s()&lt;&gt;]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,&lt;&gt;?«»“”‘’]))
  </code></pre>
  
  <p>Without any luck.. I also tried replacing the backslashes with tildes, again without luck. I've searched the internet and SO for any details about the '\' as unknown modifier but again without luck. What is going wrong here?</p>
  
  <p>A code sample included on request:</p>
  
  <pre><code>$regex = '(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:\'\".,&lt;&gt;?«»“”‘’]))';
  return !preg_match($regex, $url);
  </code></pre>
  
  <p>Thanks!</p>