I have a text file which have multiple urls with detail paths i want to get only base urls using regex
Text file contain urls like this
www.facbook.com/abc/xyz
www.google.com.pk/q=12hsjak
www.yahoo.co.uk/avga/ajak
defence.pk/zya/bahawalpur
Pic2fly.uk/abc
Want output like this
Www.facebook.com
Www.google.com.pk
Www.yahoo.co.uk
Defence.pk
Pic2fly.uk
Please help
I have tried this
Print re.search(r'(https?://)?(www\.)?([^/]*)', url)[3]