title: ruby regex test for exact match of string
body: <p>I am trying to write a regex to exactly match if a string is a mongo id, not if a string contains a mongo id.  My regex for a mongo id is</p>
  
  <pre><code>/[a-z,0-9]{24}/
  </code></pre>
  
  <p>which works great, but I can't figure out how to write a regex that rejects a URL that contains a mongo id, for example.  So, I get this, which is not what I want:</p>
  
  <pre><code>pattern = /[a-z,0-9]{24}/
  str1 = "589ab375c3c6416310171b5b"
  str2 = "http://somewhere.com/589ab375c3c6416310171b5b?review"
  str1.match pattern
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>#&lt;MatchData "589ab375c3c6416310171b5b"&gt;
  </code></pre>
  
  <p>And the second string</p>
  
  <pre><code>str2.match pattern
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>#&lt;MatchData "589ab375c3c6416310171b5b"&gt;
  </code></pre>
  
  <p>I want the first to match but the second to not.</p>
  
  <p>Thanks for any help,
  kevin </p>