Python - combine regex patterns
<p>I have a large text and the aim is to select all 10-character strings for which the first character is a letter and the last character is a digit. </p>

<p>I am a python rookie and what I managed to achieve is to find all 10-character strings:</p>

<pre><code>ten_char = re.findall(r"\D(\w{10})\D", pdfdoc)
</code></pre>

<p>Question is how can I put together my other conditions: apart from a 10-character string, I am looking for one where the first character is a letter and the last character is a digit. </p>

<p>Suggestions appreciated!</p>

<p><code>([a-z].{8}[0-9])</code></p>

<p>Will ask for 1 alphabetical char, 8 other character and finally 1 number.</p>

<p><strong>JS Demo</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var re = /([a-z].{8}[0-9])/gi; 
var str = 'Aasdf23423423423423423b423423423423423';
var m;
 
while ((m = re.exec(str)) !== null) {
    if (m.index === re.lastIndex) {
        re.lastIndex++;
    }
     console.log(m[0]);
}</code></pre>
</div>
</div>
</p>

<p><a href="https://regex101.com/r/gI8jZ4/1" rel="nofollow">https://regex101.com/r/gI8jZ4/1</a></p>

python regex