reddit-image-wall-getter/reddit_imgs/system/urlmatcher.py

13 lines
334 B
Python

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import re
from typing import List
URL_RGX_PTTRN = r'(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?'
URL_RGX = re.compile(URL_RGX_PTTRN)
def search_urls(text: str) -> List[str]:
return list(map(lambda l: l.group(0), URL_RGX.finditer(text)))