Skip to content

Instantly share code, notes, and snippets.

@abuvanth
Last active January 31, 2019 10:24
Show Gist options
  • Save abuvanth/fee78ec5f94c19291ead770a01c05a1c to your computer and use it in GitHub Desktop.
Save abuvanth/fee78ec5f94c19291ead770a01c05a1c to your computer and use it in GitHub Desktop.
import re
fil=open('hhh','r')
fil2=open('splt.txt','a')
rgx=r'(https?:\/\/[a-zA-Z0-9._\-]+)(\/.+)'
for i in fil.readlines():
m=re.search(rgx,i)
print(m.group(2)) #change 2 to 1 if you want hostname
fil2.write(m.group(2)+'\n') #change 2 to 1 if you want hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment