我有以下代码,但我不知道为什么,正则表达式与来自文件的字符串不匹配。
String s = new String(Files.readAllBytes(Paths.get("training set", "fr-le-petit-prince.txt")), StandardCharsets.UTF_8);
System.out.println(s); // Mon dessin ne representait pas un chapeau.
s = s.replaceAll("[^a-zA-Z ]", "").toLowerCase();
System.out.println(s); // empty, but the value in debugger is : mon dessin ne representait pas un chapeau.
s = "TeSt";
s = s.replaceAll("[^a-zA-Z ]", "").toLowerCase();
System.out.println(s); // test