9
文字列に\ 0(NUL)を置き換える方法は?Javaの特殊文字 0 {NUL}
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());
上記のコードは、12> 11をコンソールに表示します。おっと、どうしたの?
String e = c.replace("\0", "");
System.out.println(e); // just print 2(a bad character)2yyyy06mm
こんにちは。文字列c = "2 \ 0 \ 0 \ 0012yyyy06mm"; \t \t文字列e = c.replace( "\ 0"、 ""); \t \t System.out.println(e); \t \t \t \t // 2200yy06mm – user1900556
@ user1900556はい、その中にまだ埋め込まれている '\ 001'(2つの" 2 "の間)は見えないので、印刷します。全体のポイントは、あなたが持っている文字列 'c'はあなたが思うものを含んでいないということです。 – Alnitak
方法はありませんか?どのようにそれを行うことができますか? – user1900556