STEP 1

=IF(ISERROR(FIND(“//www.”,G2)), MID(G2,FIND(“:”,G2,4)+3,FIND(“/”,G2,9)FIND(“:”,G2,4)3), MID(G2,FIND(“:”,G2,4)+7,FIND(“/”,G2,9)FIND(“:”,G2,4)7))

where G2 is your url

STEP 2
=IF(REGEXMATCH(Q2,“\..*\..*”),RIGHT(Q2,(LEN(Q2)(FIND(“.”,Q2)0))),Q2)

where Q2 is your subdomain