Match URLs by file path and GET parameters (but not their values)
<p>How can I check if any of my list of URLs match the given <code>url</code>? I need URLs to match only if all GET parameter names (not their values) and the path are the same. For example, I have this list:</p>

<pre><code>links = [
  "http://example.com/page.php?param1=111&amp;param2=222",
  "http://example.com/page2.php?param1=111&amp;param2=222",
  "http://example.com/page2.php?param1=111&amp;param2=222&amp;someParameterN=NumberN"
  ]

url = "http://example.com/page2.php?param1=NOT111&amp;param2=NOT222"
</code></pre>

<p>This example is <code>True</code> because <code>url</code> matches <code>links[1]</code>. But how to match it in the most efficient way? I don't know what <code>url</code> will looks like.</p>

<p>I think <a href="http://www.tutorialspoint.com/python/string_split.htm" rel="nofollow">split</a> is your friend )</p>

<p>First compare <code>links[i].split('?')[0]</code> with <code>url.split('?')[0]</code></p>

<p>Then if true - split your vars with <code>'&amp;'</code>. </p>

<p>I think there exists more optimal way, i'm only a newbee, but this way will works.</p>

python regex list url match