import re


def titlecase(text):
    """
    Returns a titlecased version of text, leaving URLs as is 
    and not considering apostrophe as word separator.
    """
    re_url = re.compile(r"((?:(?:(?:(?:[a-z]+)?://)|(?:www\.))" # protocol:// or www.
                         r"(?:[\w.:_\-/?#%@]+))"                # domain + path etc
                        r"|(?:[\w\-_.]+)@(?:[\w\-_.]+))", re.I) # e-mail address
    re_inter = re.compile(r'([\s!"“#%&()*+,.\/:;?@\\[\]_`{|}~])')
    done = []
    for i, part in enumerate(re_url.split(text)):
        if i % 2:
            done.append(part) # Found URL: leave as is
            continue # for i, part

        for word in re_inter.split(part):
            if i % 2: done.append(word) # Whitespace or separator: leave as is
            elif word: done.append(word[0].upper() + word[1:].lower())
    return "".join(done)