title: Postgres regex issue
body: <p>I need to find all records stored in postgres, which matching following regexp:</p>
  
  <pre><code>^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$
  </code></pre>
  
  <p>Something like this:</p>
  
  <pre><code>SELECT * FROM users WHERE users.phone ~ '^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$'
  </code></pre>
  
  <p>But this one falls with error:</p>
  
  <blockquote>
    <p>invalid regular expression: quantifier operand invalid</p>
  </blockquote>
  
  <p>Why won't Postgres work with this regex? </p>
  
  <p>Using the same one in plain Ruby works just fine.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Problem is only with WHERE. When i try to:</p>
  
  <pre><code>SELECT '+79637434199' ~ '^((8|\+7)[\- ]?)(\(?\d{3}\)?[\- ]?)[\d\- ]{7,10}'
  </code></pre>
  
  <p>Postgres returns true. But when i try:</p>
  
  <pre><code>SELECT * FROM users WHERE users.phone ~ '^((8|\+7)[\- ]?)(\(?\d{3}\)?[\- ]?)[\d\- ]{7,10}'
  </code></pre>
  
  <p>Result: <strong>"invalid regular expression: quantifier operand invalid"</strong>.</p>