java一级域名获取
import java.util.regex.Matcher;
import java.util.regex.Pattern;
private static String regex1="[0-9a-zA-Z]+((\\.com)|(\\.cn)|(\\.org)|(\\.net)|(\\.edu)|(\\.com.cn))"; Pattern p = Pattern.compile(regex1); Matcher m = p.matcher(url); List<String> strList = new ArrayList<String>(); while(m.find()){ strList.add(m.group()); } String categoryId = strList.toString(); categoryId = categoryId.substring(1,categoryId.length()-1);