Python - Most elegant way to extract a substring, being given left and right borders : <p>I have a string - Python :</p>

<pre><code>string = "/foo13546897/bar/Atlantis-GPS-coordinates/bar457822368/foo/"
</code></pre>

<p>Expected output is :</p>

<pre><code>"Atlantis-GPS-coordinates"
</code></pre>

<p>I know that the expected output is ALWAYS surrounded by "/bar/" on the left and "/" on the right :</p>

<pre><code>"/bar/Atlantis-GPS-coordinates/"
</code></pre>

<p>Proposed solution would look like :</p>

<pre><code>a = string.find("/bar/")
b = string.find("/",a+5)
output=string[a+5,b]
</code></pre>

<p>This works, but I don't like it.
Does someone know a beautiful function or tip ?</p>
