用java正则表达式怎么求出
http://community.csdn.net/Expert/PostNew.asp
中的PostNew.asp??

解决方案 »

  1.   

    url="http://127.0.0.1/post1.do?paramId=1&paramName=name#top"
    public static String getHref(String href){
    Pattern s=Pattern.compile("http://.*/(.*)\\?");
    Matcher m=s.matcher(href);
    if(m.find())
    return m.group(1);
    else
    return null;
    }
    如果url没有问号
    就换为这个
    Pattern s=Pattern.compile("http://.*/(.*)$");
      

  2.   

    不用正则,这样就能求出:
    String str ="http://community.csdn.net/Expert/PostNew.asp";
    int i = str.lastIndexOf('/');
    if (i > 0 && i < str.length() - 1) {
        System.out.println(str.substring(i+1).toLowerCase());
    }