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);

 

posted @ 2014-07-01 20:13  箜篌  阅读(2900)  评论(0编辑  收藏  举报