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>Judging by the provided sample input data, this is an XML and should be parsed with <em>specialized</em> tools like <a href="https://docs.python.org/2/library/xml.etree.elementtree.html" rel="nofollow"><code>xml.etree.ElementTree</code></a> or <a href="http://lxml.de/" rel="nofollow"><code>lxml</code></a>. To get to the data after the first hyphen, we'll use <a href="https://docs.python.org/2/library/stdtypes.html#str.split" rel="nofollow"><code>str.split()</code></a> providing the <code>maxsplit</code> value of 1 and getting the last item of the result:</p>

<pre><code>import xml.etree.ElementTree as ET

data = """
&lt;root&gt;
    &lt;details&gt;Fiction - Mystery - Duvall&lt;/details&gt;
    &lt;details&gt;Fiction - Mystery - Horror -  Duvall&lt;/details&gt;
&lt;/root&gt;"""

root = ET.fromstring(data)
for details in root.findall("details"):
    text = details.text
    print(text.split(" - ", 1)[1])
</code></pre>

<p>Prints:</p>

<pre><code>Mystery - Duvall
Mystery - Horror -  Duvall
</code></pre>

python regex