我有一个这样的字符串数组:
String tweetString = ExudeData.getInstance().filterStoppingsKeepDuplicates(tweets.text);
// get array of words and split
String[] wordArray = tweetString.split(" ");
拆分数组后,我打印以下内容:
System.out.println(Arrays.toString(wordArray));
我得到的输出是:
[new, single, fallin, dropping, days, artwork, hueshq, production, iseedaviddrums, amp, bigearl7, mix, reallygoldsmith, https, , , t, co, dk5xl4cicm, https, , , t, co, rvqkum0dk7]
我想要的是删除逗号,https和单个字母(如“t”)的所有实例(使用上述方法后)。所以我想以这个结束:split
[new, single, fallin, dropping, days, artwork, hueshq, production, iseedaviddrums, amp, bigearl7, mix, reallygoldsmith, co, dk5xl4cicm, https, co, rvqkum0dk7]
我尝试过做替换所有像这样:
String sanitizedString = wordArray.replaceAll("\\s+", " ").replaceAll(",+", ",");
但这只是给了我相同的初始输出,没有变化。有什么想法吗?
九州编程
有只小跳蛙
阿晨1998
相关分类