Come sostituire \ 0 (NUL) nella stringa?Caratteri speciali 0 {NUL} in Java
String b = "2012yyyy06mm"; // sth what i want
String c = "2\0\0\0012yyyy06mm";
String d = c.replaceAll("\\\\0", ""); // not work
String e = d.replace("\0", ""); // er, the same
System.out.println(c+"\n"+d+"\n"+e);
String bb = "2012yyyy06mm";
System.out.println(b.length() + " > " +bb.length());
Il codice precedente stamperà 12> 11 in console. Oops, cosa è successo?
String e = c.replace("\0", "");
System.out.println(e); // just print 2(a bad character)2yyyy06mm
Ciao, tls per aiuto. Stringa c = "2 \ 0 \ 0 \ 0012aaaa06mm"; \t \t Stringa e = c.replace ("\ 0", ""); \t \t System.out.println (e); \t \t \t \t // stampa solo 22yyyy06mm – user1900556
@ user1900556 sì, perché il '\ 001' ancora incorporato in esso (tra i due" 2 ") è invisibile. Il punto è che la stringa 'c' che hai non contiene ciò che pensi che faccia. – Alnitak
Non c'è modo? In quale altro modo può essere fatto? – user1900556