def fix_urls(text):
    pat_url = re.compile(
        """
                     (?x)( 
         (http|ftp|gopher) 
                       :// 
            (\\w+[:.]?){2,} 
                      (/?| 
                [^ \\n\\r"]+ 
                    [\\w/]) 
         (?=[\\s\\.,>)'"\\]]) 
                         ) 
                           """
        )
Detect URLs in a string and wrap with "<a href..." tag