regex match space forward slash and space ' / '
<p>Here is my string 'something / something else'
I would like to match with regex everything up to <code>/</code> i.e space forward slash space again. Here is what I tried =<code>/.+?(?=\s//\s)/</code>, but it does not work. It says: 'pattern contains no capture groups'. I am using it with pandas extract function.</p>

<p>Do:</p>

<pre><code>r'^([^/]+) / '
</code></pre>

<ul>
<li><code>^([^/]+)</code> matches everything upto the <code>/</code>, then <code>/</code> matches a space, then <code>/</code>, and then a space again. SO the captured group 1 will only have the portion upto the space before <code>/</code></li>
</ul>

<p><strong>Example:</strong></p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; s = 'something / something else'
&gt;&gt;&gt; re.search(r'^([^/]+) / ', s).group(1)
'something'
</code></pre>

python regex pandas