Use regex to verify an ISBN number
<p>I need a regex to verify ISBN number entered by user.</p>

<p>ISBN must be a string contains only:
<code>[10 or 13 digits] and hyphens</code></p>

<p>I tried <code>^[\d*\-]{10}|[\d*\-]{13}$</code> but it doesn't work.</p>

<p>My regex only matches: <code>978-1-5661</code>, <code>1-56619-90</code>, <code>1257561035</code></p>

<p>It should returns the results below:</p>

<pre><code>"978-1-56619-909-4 2" =&gt; false
"978-1-56619-909-4" =&gt; true
"1-56619-909-3 " =&gt; false
"1-56619-909-3" =&gt; true
"isbn446877428ydh" =&gt; false
"55 65465 4513574" =&gt; false
"1257561035" =&gt; true
"1248752418865" =&gt; true
</code></pre>

<p>I really appreciate any help.</p>