
- 加为好友
- 发送私信
- 在线聊天
|
| 发表于:2007-10-09 21:12:161楼 得分:40 |
不明白标签是什么 所以不太清楚楼主的要求 是不是 转后变成这个效果: <root id= 'tt ' > <![CDATA[111 3333]] > <root > <basisInfo > <![CDATA[111 3333]] > 是的话 我的代码是: public class StrC { public static String str= " <root id= 'tt ' > <![CDATA[111 3333]] > <root > <basisInfo > <![CDATA[111 3333]] >"; public String chang(String str, String start, String end, String s1, String s2) { int len1=0,len2=0; do{ len1=str.indexOf(" <![CDATA",len2); if (len1!=-1) { len2=str.indexOf(">",len1); String temp=str.substring(len1,len2); temp=temp.replaceAll(s1,s2); str=str.substring(0,len1)+temp+str.substring(len2); } } while (len1!=-1); return str; } public static void main(String[] args) { StrC sc=new StrC(); String result=sc.chang(str," <![CDATA",">"," "," "); System.out.println(result); } } | | |
修改
删除
举报
引用
回复
| |