怎么去除网址字符串里面的 /  :符号
比如http://forum.csd::::n.net/PointF:orum/Fo:rum/PostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803
要变成httpforum.csdn.netPointForumForumPostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803
要确切可用的哦~亲

解决方案 »

  1.   


    String str="http://forum.csd::::n.net/PointF:orum/Fo:rum/PostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803";
    StringBuffer sb=new StringBuffer();
    for(int i=0;i<str.length();i++){
    if(str.charAt(i)!=':'&&str.charAt(i)!='/'){
    sb.append(str.charAt(i)+"");
    }
    }
    System.out.println(sb.toString());:用的是英文的冒号。
      

  2.   

    用正则呗: public static void main(String[] args) {
    String s = "http://forum.csd::::n.net/PointF:orum/Fo:rum/PostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803";
    System.out.println(s.replaceAll("[/|\\:|:|\\s+]", ""));
    }
      

  3.   

    public class Test {
    public static void main(String[] args) {
    // test1
            String strtest = "http://forum.csd::::n.net/PointF:orum/Fo:rum/PostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803";
            strtest = strtest.replaceAll("[/::]*", "");
            System.out.print(strtest);
    }
    }
    結果:httpforum.csdn.netPointForumForumPostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803LZ试试看
      

  4.   


    String url = "http://forum.csd::::n.net/PointF:orum/Fo:rum/PostTopic.aspx?forumID=3931c03e-b66c-4189-a4f0-210fd9501803";
    System.out.println(url.replaceAll("[/::]+", ""));