def urlMapper src match url src match start match end for regex handle

1
2
3
4
5
6
7
8
def urlMapper(src, match):
url = src[match.start():match.end()]
for (regex, handler) in MAPPERS:
if regex.match(url):
return handler(url)
return url
tweet = URLRX.subn(lambda x: urlMapper(tweet, x), tweet)[0]