Skip to content

Instantly share code, notes, and snippets.

@jphastings
Created December 27, 2009 02:01
Show Gist options
  • Select an option

  • Save jphastings/264122 to your computer and use it in GitHub Desktop.

Select an option

Save jphastings/264122 to your computer and use it in GitHub Desktop.
import re
files = ["bbc.co.uk.js","bbc.co.uk>radio1>chart.js","bbc.co.uk>*>playlists.js"]
doms = ["www.bbc.co.uk/radio1/chart/singles","bbc.co.uk","bbc.co.uk/radio1/playlists/","bbcnco.uk","notthebbc.co.uk"]
# Goes to line 185
files.sort()
files.reverse()
for domain in doms:
print "Domain: "+domain
# Goes to Line 186
for filename in files:
if filename.endswith('.js'):
sre = re.compile('(.+\.)?'+re.escape(filename.split('.js')[0].replace('>','/')).replace('\*','.+'))
if sre.match(domain):
print " - matches: "+filename
break
Domain: www.bbc.co.uk/radio1/chart/singles
- matches: bbc.co.uk>radio1>chart.js
Domain: bbc.co.uk
- matches: bbc.co.uk.js
Domain: bbc.co.uk/radio1/playlists/
- matches: bbc.co.uk>*>playlists.js
Domain: bbcnco.uk
Domain: notthebbc.co.uk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment