String after last hypen with 1-N Hypens in Regex (Python)
<p>Given a pattern (<a href="https://regex101.com/r/iN9hG6/2" rel="nofollow">https://regex101.com/r/iN9hG6/2</a>) which can have N # of hypens where I want the text after the last one, how would I request that as I always get the first:</p>

<p><code>&lt;details&gt;Fiction - Mystery - Duvall&lt;/details&gt;</code></p>

<p><code>&lt;details&gt;Fiction - Mystery - Horror -  Duvall&lt;/details&gt;</code></p>

<p>Where I want Duvall in each case.</p>

<p>Disclaimer: for anyone following my questions, I realize this looks a lot like</p>

<p><a href="http://stackoverflow.com/questions/39150414/finding-the-last-specific-character-type-in-a-string">Finding the last specific character type in a string</a></p>

<p>but I tried to apply that solution to no avail. Possibly not totally understanding it as a relative Regex newbie, just didn't want the person who did answer that to think I ignored them and was asking for duplicate work.</p>

<p>I think what you're looking for is this:</p>

<pre><code>&lt;details&gt;(?:\w+ - *)*(\w+)&lt;\/details&gt;
</code></pre>

<p>The idea is to match as much as possible inside the (?: ) group, which doesn't cause a backreference to be made, then match the thing you actually care about - the last token. The example below should give a bit more insight into what the syntax means.</p>

<p><a href="https://regex101.com/r/iN9hG6/2" rel="nofollow">Example</a></p>

python regex