Regex to parse out a part of URL
<p>I am having the following data,</p>

<pre><code>data
http://hsotname.com/2016/08/a-b-n-r-y-u
https://www.hostname.com/best-food-for-humans
http://www.hostname.com/wp-content/uploads/2014/07/a-w-w-2.jpg
http://www.hostname.com/a/geniusbar/
http://www.hsotname.com/m/
http://www.hsotname.com/
</code></pre>

<p>I want to avoid the first http:// or https:// and check for the last '/' and parse out the remaining parts of the URL. But the challenge here is, we have '/' on the end of few URLs as well. The output which I want is,</p>

<pre><code>parsed
a-b-n-r-y-u
best-food-for-humans
a-w-w-2.jpg
NULL
NULL 
NULL
</code></pre>

<p>Can anybody help me to find the last / and parse out the remaining part of the URL? I am new to regex and any help would be appreciated.</p>

<p>Thanks</p>

<p>Regex isn't the best tool in this case. Just use str.rfind:</p>

<pre><code>[url[url.rfind('/'):] for url in data]
</code></pre>

<p>Will give you what you're looking for</p>

python regex regex-negation