capture all matches in regex (g modifier not working for me)
<p>If I want to capture all of the last term in each product in this pattern:</p>

<pre><code>PatternAnchor: Product-Computer-Keyboard, 
Product-Computer-Monitor, Product-Computer-Motherboard PatternEnd:
</code></pre>

<p>I tried this:</p>

<pre><code>PatternAnchor: Product-(.*?)-(?P&lt;Item&gt;.*?)(,|PatternEnd:)
</code></pre>

<p>but I still only get the first match.</p>

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

<p>If you want to match multiple strings starting with <code>Product-</code> with <code>PatternAnchor:</code> at start then you can use this PCRE regex with <code>\G</code></p>

<pre><code>(?:PatternAnchor: |\G\h*,\h*)Product-([^-]*)-(?P&lt;Item&gt;[^,\h]*)(?=,|\h*PatternEnd:)
</code></pre>

<p><a href="https://regex101.com/r/cR0aG8/3" rel="nofollow">RegEx Demo</a></p>

<p><code>\G</code> asserts position at the end of the previous match or the start of the string for the first match.</p>

<hr>

<p>Based on comments it seems OP wants a python specific regex. Since <code>\G</code> is not available in python regex one can use:</p>

<pre><code>\bProduct-([^-]*)-(?P&lt;Item&gt;[^,\s]*)(?=,|\s*PatternEnd:)
</code></pre>

<p>and a separate check to ensure input starts with <code>PatternAnchor:</code>.</p>

<p><a href="https://regex101.com/r/cR0aG8/4" rel="nofollow">RegEx Demo</a></p>

python regex