public static void main(String[] args) {
Pattern pattern = Pattern.compile("[a-zA-Z]+"); // 匹配英文字母
List<String> wordList = new ArrayList<>();
String filePath = "C:/english-wordlists-master/english-wordlists-master/红宝书 GRE词汇精选.csv";
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line;
while ((line = reader.readLine()) != null) {
// 分割CSV行
String[] parts = line.split(",");
// 提取每个部分中的英文单词
for (String part : parts) {
Matcher matcher = pattern.matcher(part);
while (matcher.find()) {
String word = matcher.group();
wordList.add(word);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// 打印提取到的英文单词
for (String word : wordList) {
System.out.println(word);
}
}