optimized the code, Extract domain and subdomain from regex