import java.util.regex.*;public class A{
  public static void main( String[] args ){
    String str = "http://sports.sina.com.cn";
    Pattern p = Pattern.compile( "http://[\\w\\-]*?\\.(.*?)(\\..*?)+", Pattern.CASE_INSENSITIVE );
    Matcher m = p.matcher( str );
    String domain;
    if (m.find()) {
       domain = m.group(1);
    } else {
        domain = "XXX";
    }
    System.out.println( domain );
  }
}
OK?