for m in URLRX.finditer(tweet):
(fro, to) = m.span()
url = m.group(1)
res += tweet[prev:fro]
prev = to
for (regex, handler) in URLSOLVERS:
match = regex.match(url)
if match:
res += handler(match)
break
for (mo,mf) in MAPPERS:
mx = mo.match(url)
if mx:
res += mf(mx)
break
tweet = res + tweet[prev:]