Python regular expression: exact match only : <p>I have a very simple question, but I can't find an answer for this.</p>

<p>I have some string like:</p>

<pre><code>test-123
</code></pre>

<p>I want to have some <code>smart</code> regular expression for validation if this string exact match my condition.</p>

<p>I expect to have a strings like:</p>

<pre><code>test-&lt;number&gt;
</code></pre>

<p>Where number should contains from 1 to * elements on numbers.</p>

<p>I'm trying to do something like this:</p>

<pre><code>import re
correct_string = 'test-251'
wrong_string = 'test-123x'
regex = re.compile(r'test-\d+')
if regex.match(correct_string):
    print 'Matching correct string.'
if regex.match(wrong_string):
    print 'Matching wrong_string.'
</code></pre>

<p>So, I can see both messages (with matching correct and wrong string), but I really expect to match only correct string.</p>

<p>Also, I was trying to use <code>search</code> method instead of <code>match</code> but with no luck.</p>

<p>Ideas?</p>
