import re


def mask_url(txt):

    """
        Finds an url pattern and then masks it.

        Parameters
        -----------
        txt:  str
            A piece of text containing the url pattern


        Returns
        -----------
        str
            masked url string as ' [url] '

        list
            list with the found pattern(s)

    """
        
    pattern='http\S+'
    pattern2='www\S+'
    sub=' [url] '

    txt, find = re.sub(pattern, sub, txt, flags=re.I), re.findall(pattern, txt, flags=re.I)
    txt, find2 = re.sub(pattern2, sub, txt, flags=re.I), re.findall(pattern2, txt, flags=re.I)

    return txt, find+find2