title: Why does / matches /something?
body: <p>I just noticed a bug in my app.</p>
  
  <p>In my table, I store regular expression patterns and match them with an input.</p>
  
  <p>In the table, I have '/' pattern (it was test data) stored.</p>
  
  <p>to use '/' in php, I have the following code</p>
  
  <pre><code>$input = '/something';
  $pattern = '/'.str_replace('/', '\/', $pattern).'/';
  preg_match($pattern, $input, $matches);
  </code></pre>
  
  <p>why do I get a match in this case? How do I prevent it?</p>