Compare & manipulate strings with python
<p>I've written an <a href="http://pastebin.com/D9DkQdEv" rel="nofollow">XML parser</a> in Python and have just <a href="http://pastebin.com/Y0DjtwHu" rel="nofollow">added functionality</a> to read a further script from a different directory.</p>

<p>I've got two args, first is the path where I'm parsing XML. Second is a string in another XML file which I want to match with the first path;</p>

<p><code>arg1 = \work\parser\main\tools\app\shared\xml\calculators\2012\example\calculator</code><br>
<code>path = calculators/2012/example/calculator</code></p>

<p>How can I compare the two strings to match identify that they're both referencing the same thing and also, how can I strip <code>calculator</code> from either string so I can store that &amp; use it?</p>

<p><em>edit</em></p>

<p>Just had a thought. I have used a Regex to get the year out of the path already with <code>year = re.findall(r"\.(\d{4})\.", path)</code> following a problem Python has with numbers when converting the path to an import statement.</p>

<p>I could obviously split the strings and use a regex to match the path as a pattern in arg1 but this seems a long way round. Surely there's a better method?</p>
