String  str="<HTML><IMG src="/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"><IMG src="/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"><IMG src="/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"></HTML>"我想把src="/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/XX.gif"的所有图片路径换成
  src=" http://localhost:8080/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/02.gif"
请 各位高手 指点

解决方案 »

  1.   

    /eWebEditor_demo/htmlEditor/eWebEditor/sysimage/ 都相同
     参考如下
    String str="csdnandj2seandcsdn";
    str.replace("csdn", "nbchina");
    System.out.println(str);
      

  2.   

     在编辑器中ctrl+f就可以了呀
      

  3.   


    public class StringDLL { static String str = "<HTML>"
    + "<IMG src=\"/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif\">"
    + "<IMG src=\"/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif\">"
    + "<IMG src=\"/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif\">"
    + "</HTML>";
    static String relStr = "http://localhost:8080"; public static void main(String[] args) {
    System.out.println(str
    .replaceAll("(<IMG\\s+src=\\s*\")([^\"]+)(\"\\s*>)", "$1"
    + subStr + "$2$3"));
    }}
      

  4.   

    把主函数中的subStr改成relStr,不好意思,马虎了一下;
    运行结果如下:<HTML><IMG src="http://localhost:8080/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"><IMG src="http://localhost:8080/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"><IMG src="http://localhost:8080/eWebEditor_demo/htmlEditor/eWebEditor/sysimage/emot/09.gif"></HTML>
      

  5.   

    String str = "aaabcdef";
    System.out.println(str.replaceAll("a", "b"));
      

  6.   

    使用字符串的replace方法即可