python - Regular expression to search only websites names from random text -
i want create regular expression search , return website names text.
e.g.
"hello, total description of deals below: mango: maangobar22.com total deals : 0 apple: myapplesite22.com total deals : 3 berrymine22.com total deals : 0 hope hear soon"
i want search websites name , store them in different variable.
i created following re since new re, unable think start.
import re import sys text = "hello, total description of deals below: mango: maangobar22.com total deals : 0 apple: myapplesite22.com total deals : 3 berrymine22.com total deals : 0 hope hear soon" num = re.match(r'+..com', "", text) print('phone num : ', text) a1 = num.group() a2 = num.group(1) a1 = num.group(2) a2 = num.group(3)
any highly appreciated.
you use following example:
import re websites = re.findall(r'(\s+[.]com)', text) # ['maangobar22.com', 'myapplesite22.com', 'berrymine22.com']
Comments
Post a Comment