Regex to match repeated set of characters
<p>I'd like to be able to extract the following patterns from free text.</p>

<pre><code>VBAV/123456.01
VBAV/132453.02
VSAV/132452.01.03
VMAV/142143.01.02
</code></pre>

<p>Currently I am trying as below but not much success</p>

<pre><code>df["Project Id"] = df["WBS element"].str.cat(
df["Network VxAV"]).str.cat(
df["Text"]).str.cat(
df["Assignment"]).str.cat(
df["Reference"]).str.extract(
"(V[BSM]AV\/[\d]{6}[.0-30-3]{0,2})", expand=True)
</code></pre>

<p>The challenging part for me was to extract the patterns of repeated .01 or .02 or .03 at the end. This part can repeat between 0 to 2 times, hence my attempt with {0,2} with the regex.</p>

<p>What would be the right regex for this? </p>

<p>consider the the <code>pd.Series</code> <code>s</code></p>

<pre><code>s = pd.concat([pd.Series(txt.split('\n')) for _ in range(3)], ignore_index=True)
</code></pre>

<p><strong><em>Option 1</em></strong><br>
my preference</p>

<pre><code>s.str.split('/', expand=True)
</code></pre>

<p><a href="http://i.stack.imgur.com/B8ejM.png" rel="nofollow"><img src="http://i.stack.imgur.com/B8ejM.png" alt="enter image description here"></a></p>

<p><strong><em>Option 2</em></strong><br>
Also Nice</p>

<pre><code>s.str.extract(r'(?P&lt;first&gt;\w+)/(?P&lt;second&gt;.*)', expand=True)
</code></pre>

<p><a href="http://i.stack.imgur.com/MFCJm.png" rel="nofollow"><img src="http://i.stack.imgur.com/MFCJm.png" alt="enter image description here"></a></p>

<p><strong><em>Option 3</em></strong><br>
Very Explicit</p>

<pre><code>cols = ['first', 'second']
s.str.extract(r'(?P&lt;first&gt;V[BSM]AV)/(?P&lt;second&gt;\d{6}(.\d{2})+)', expand=True)[cols]
</code></pre>

<p><a href="http://i.stack.imgur.com/MFCJm.png" rel="nofollow"><img src="http://i.stack.imgur.com/MFCJm.png" alt="enter image description here"></a></p>

python regex pandas