[Solved] Which of the following regular expressions can be used to get the domain name? python [closed]


You selected the correct regexp, you just have to quote it to use it in Python. You also need to call re.findall(), it’s not a string method.

import re

txt="I refer to https://google.com and i never refer http://www.baidu.com"
print(re.findall(r'(?<=https:\/\/)([A-Za-z0-9.]*)', txt))

1

solved Which of the following regular expressions can be used to get the domain name? python [closed]