Javascript regex for extracting certain part of string
<p>I need to extract certain part of Javascript string. I was thinking to do it with regex, but couldn't come up with one which does it correctly.</p>

<p>String can have variable length &amp; can contain all possible characters in all possible combinations.</p>

<p>What I need to extract from it, is 10 adjacent characters, that match one of next two possible combinations:</p>

<ol>
<li>9 numbers &amp; 1 letter "X" (capital letter "X", not X as variable letter!)</li>
<li>10 numbers</li>
</ol>

<p>So, if input string is this: "[1X,!?X22;87654321X9]ddee", it should return only "87654321X9".</p>

<p>I hope I've explained it good enough. Thanks in advance!</p>