if text.startswith('http://'):
    text = text.replace('http://', '', 1)
elif text.startswith('https://'):
    text = text.replace('https://', '', 1)
if text.startswith('www.'):
    text = text.replace('www.', '', 1)
if len(text) > maxlinklength:
    halflength = maxlinklength / 2
text = text[0:halflength] + '...' + text[len(text) - halflength:]
return '<a class="comurl" href="' + url + '" target="_blank" rel="nofollow">' + text + '<img class="imglink" src="/images/linkout.png"></a>'
if text != None and text != '':
    return _urlfinderregex.sub(replacewithlink, text)
else:
    return ''
replace URLs in text with links to URLs