这是我的第一个问题,抱歉我的英语不好
我只想从包含字母和数字组合的字符串中提取单词并将其存储在数组中
我尝试了这段代码,但我没有得到我想要的结果
String temp = "74 4F 4C 4F 49 65 brown fox jump over the fence";
String [] word = temp.split("\\W");
这是我想要的结果(只有单词,没有空数组)
brown
fox
jump
over
the
fence
请帮忙,谢谢!
最佳答案
根据@anubhava 的回答,你可以做类似的事情
String temp = "74 4F 4C 4F 49 65 brown fox jump over the fence";
Pattern pattern = Pattern.compile("\\b[A-Za-z]+\\b");
Matcher matcher = pattern.matcher(temp);
while (matcher.find()) {
System.out.println("Matched " + matcher.group());
}
关于java - 从java中具有字母和数字组合的字符串中提取单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19741189/