Trying to split string with regex
<p>I'm trying to split a string in Python using a regex pattern but its not working correctly.</p>

<p>Example text:</p>

<p><code>"The quick {brown fox} jumped over the {lazy} dog"</code></p>

<p>Code:</p>

<p><code>"The quick {brown fox} jumped over the {lazy} dog".split(r'({.*?}))</code></p>

<p>I'm using a capture group so that the split delimiters are retained in the array.</p>

<p>Desired result:</p>

<p><code>['The quick', '{brown fox}', 'jumped over the', '{lazy}', 'dog']</code></p>

<p>Actual result:</p>

<p><code>['The quick {brown fox} jumped over the {lazy} dog']</code></p>

<p>As you can see there is clearly not a match as it doesn't split the string. Can anyone let me know where I'm going wrong? Thanks.</p>

<p>You're calling the strings' split method, not re's</p>

<pre><code>&gt;&gt;&gt; re.split(r'({.*?})', "The quick {brown fox} jumped over the {lazy} dog")
['The quick ', '{brown fox}', ' jumped over the ', '{lazy}', ' dog']
</code></pre>

python regex