sub.getthisname.xyz/etcetc
How to get the middle name between two dot if have subdomain? getthisname
I try something (\w)+(?:\.\w{2,3})+(?:[\/])+(.)*$
Thanks!
sub.getthisname.xyz/etcetc
How to get the middle name between two dot if have subdomain? getthisname
I try something (\w)+(?:\.\w{2,3})+(?:[\/])+(.)*$
Thanks!
Will your code run in a browser?
UPDATE: Actually, browser URL API won’t help here… Production-wise it would be quite hard problem. Scenario-wise, if it’s a part of test and you more or less can predict input, then you can solve it child-ish way with split()
method:
new URL(url).hostname.split('.').slice(-2)[0]
ResponseURL = 'sub.getthisname.xyz/etcetc'
var domain = ResponseURL.split('.');
alert(domain[domain.length - 2]);
I do something this.
Thanks!