使用Java正则表达式获取url地址中的主域名代码如下:

Pattern.compile("[^//]*?\\.(com|cn|net|org|biz|info|cc|tv)", Pattern.CASE_INSENSITIVE);