java从字符串中删除字母数字单词
我正试图从字符串中删除字母数字单词
String[] sentenceArray= {"India123156 hel12lo 10000 cricket 21355 sport news 000Fifa"};
for(String s: sentenceArray)
{
String finalResult = new String();
String finalResult1 = new String();
String str= s.toString();
System.out.println("before regex : "+str);
String regex = "(\\d?[,/%]?\\d|^[a-zA-Z0-9_]*)";
finalResult1 = str.replaceAll(regex, " ");
finalResult = finalResult1.trim().replaceAll(" +", " ");
System.out.println("after regex : "+finalResult);
}
输出:hel lo板球运动新闻Fifa
但我需要的输出是:板球运动新闻
伙计们请帮帮我。。 提前谢谢
# 1 楼答案
O/p: