Regex for format ( HHh MMs SSs ) with optional hours
<p>I am struggling to get a regex working for the below format. Pointers appeciated</p>

<pre><code>( 43m 12s )
( 13m 11s )
( 11h 43m 12s )
( 1h 43m 12s )
</code></pre>

<p>Edit:</p>

<p>The above examples are part of longer strings.</p>

<p>Edit2:</p>

<p>This is what I have now:</p>

<pre><code> \s\(\s\d{1,2}[a-z]\s.*\)
</code></pre>

<p>If you don't need to capture hours minutes and seconds, this will work: <code>\(\s?(?:\d{1,2}\w )+\s?\)</code> you can see it working here: <a href="https://regex101.com/r/yC8iH6/1" rel="nofollow">https://regex101.com/r/yC8iH6/1</a></p>

<p><strong>[EDIT]</strong>: Add capturing if needed:</p>

<p>If you need to capture you can do this:
<code>\(\s?(?:(\d{1,2})\w\s?)?(?:(\d{1,2})\w\s?)(?:(\d{1,2})\w\s?)\s?\)</code>. Notice that the first grouping is optional. </p>

<p>You can see this working version here: <a href="https://regex101.com/r/yC8iH6/2" rel="nofollow">https://regex101.com/r/yC8iH6/2</a>.</p>

<p>Also mote that first non capturing regex can be written like this for more accuracy <code>\(\s?(?:\d{1,2}\w ){2,3}\s?\)</code>.</p>

<p>Hope this helps :)</p>

python regex