regular expression to extract url parts

/^(https?)://((?:[A-Z0-9]*\.?)*)((?:\/?[A-Z0-9])*)/i

example text:
https://github.com/jonmagic/scriptular
http://scriptular.com
http://www.google.com
http://www.guardian.co.uk

Match Results:
https://github.com/jonmagic/scriptular
http://scriptular.com
http://www.google.com
http://www.guardian.co.uk

Match Groups:
Match 1
https
github.com
/jonmagic/scriptular

Match 2
http
scriptular.com

Match 3
http
www.google.com

Match 4
http
www.guardian.co.uk

Leave a Reply