62,616
社区成员
发帖
与我相关
我的任务
分享
public class Test {
public static void main(String[] args) {
String xml = "<listenPort>8000</listenPort>,<listenPort>2000</listenPort>";
String regex = "(<listenPort>)([0-9]+)(</listenPort>)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(xml);
while(m.find()){
xml = m.replaceAll("$13000$3");
}
System.out.println(xml);
}
}