title: mysql REGEXP exact pattern match
body: <p>I'm working on writing a php script that will loop through all tables in database and look for plain text credit card numbers. For this I'm using MySQL REGEXP. I need only those results which "only" contains credit card numbers. If there is any textual data that contains credit card number then the script should not consider it.</p>
  
  <p>e.g.</p>
  
  <p>|&nbsp;&nbsp;&nbsp;id&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ccno&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4111111111111111&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4111 1111 1111 1111&nbsp;&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4111-1111-1111-1111&nbsp;&nbsp;&nbsp;|<br>
  |&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;| some text 4111111111111111 some text |<br></p>
  
  <p>If the query is trieggered on above table then it should return first 3 records, it should not return 4th record. For this purpose I'm using below query and the issue I'm facing is the query is returning all the 4 records.</p>
  
  <pre><code>SELECT ccno FROM aacc WHERE 
  (ccno = REGEXP '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  OR ccno = REGEXP '[0-9][0-9][0-9][0-9] [0-9][0-9][0-9][0-9] [0-9][0-9][0-9][0-9] [0-9][0-9][0-9][0-9]'
  OR ccno = REGEXP '[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]')
  </code></pre>