Lo que estoy intentando es separar una cadena String de otra...pero no entiendo porque me da este error...
package GUI;
public class m {
public static void main(String[] args) {
String ruta = "C:\\Users\\PcPortatil\\Pictures\\";
String username = System.getProperty("user.name");
String delimitador = "C:\\Users\\" + username;
String NuevaRuta = ruta.replaceAll(delimitador, "");
System.out.println(NuevaRuta);
}
}
Me da este error:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3
C:\Users\PcPortatil
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.escape(Unknown Source)
at java.util.regex.Pattern.atom(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at GUI.m.main(m.java:11)