js: how to intercept the suffix of domain name

I need to intercept the suffix in the domain name. How can I intercept the content between the last letter and the first /

let str1 = 'https://mail.xxx.net/main/';
// net

let str2 = 'https://blog.xxx.me/';
// me

let str3 = 'https://xxx.blog.com/home';
// com

let str4 = 'https://xxx.blog/home/#container';
// blog



You can do this using a simple regex:

const url = 'https://xxx.blog/home/#container';

const domain = url.match(/^https?://.+.([^/]+)/.*/);