public class Test { public static void main(String[] args) { String s="/LLL/AAA\\FFF\\DDD\\GGG"; System.out.println(s.replaceAll("\\","/")); } } //编译过去,运行出错晕
public class Test { public static void main(String[] args) { String s="/LLL/AAA\\FFF\\DDD\\GGG"; System.out.println(s.replace('\\','/')); } } //字符就ok,不知道何解,纳闷^_^
{
public static void main(String[] args)
{
String s="/LLL/AAA\\FFF\\DDD\\GGG";
System.out.println(s.replaceAll("\\","/"));
}
} //编译过去,运行出错晕
{
public static void main(String[] args)
{
String s="/LLL/AAA\\FFF\\DDD\\GGG";
System.out.println(s.replace('\\','/'));
}
} //字符就ok,不知道何解,纳闷^_^
public class replace {
public static void main(String[] args) throws Exception {
Pattern p = Pattern.compile("\\");
Matcher m = p.matcher("/LLL/AAA\\FFF\\DDD\\GGG");
StringBuffer sb = new StringBuffer();
int i=0;
boolean result = m.find();
while(result) {
i++;
m.appendReplacement(sb, "/");
result = m.find();
}
m.appendTail(sb);
System.out.println("string="+ sb.toString());
}
}