Assist with re Module
<p>I need to extract all those strings between the patterns nr: or /nr:. Can anyone please help me?</p>

<p>The string is </p>

<pre><code>nr:Organization/nr:Customer/nr:Agreement/nr:date/nr:coverage/nr:Premium/nr:Option/nr:OptionID
</code></pre>

<p>Output I am expecting is</p>

<pre><code>Organization, Customer, Agreement,...OptionID
</code></pre>

<p>Use the <code>re</code> module, <code>split</code> the string and filter out matches whose lengths are 0:</p>

<pre><code>import re

test_string = "nr:Organization/nr:Customer/nr:Agreement/nr:date/nr:coverage/nr:Premium/nr:Option/nr:OptionID"

columns = [x for x in re.split("/{0,1}nr:",test_string) if len(x) &gt; 0]

print(columns)

['Organization', 'Customer', 'Agreement', 'date', 'coverage', 'Premium', 'Option', 'OptionID']
</code></pre>

<p>I hope this helps.</p>

python