日期:2014-05-20 浏览次数:20647 次
public static void main(String[] args) { String str = "www.aa.com/bb/content2/slakdfjsdkf.com"; str = str.substring(0, str.lastIndexOf("/")); System.out.println(str); str = str.substring(str.lastIndexOf("/") + 1); System.out.println(str); }
------解决方案--------------------
public static void main(String[] args) { String arr[] = new String[]{ "www.aa.com/bb/content1/xxx.com", "www.aa.com/bb/content2/slakdfjsdkf.com" }; for(int i=0;i<arr.length;i++){ String str = arr[i]; System.out.println(str.replaceAll(".*bb/(.*?)/.*","$1")); } }