所以这里有一个代码,可以从不是字母字符的符号中清除文本。然后它将文本拆分为单词。然后删除不是从元音开始的单词和没有第二个字符的单词。但是,当您输入大文本字符串时,此功能无法正常工作
input = new StringBuffer("some text will be here");
System.out.println("Начальная строка - " + input.toString());
input = new StringBuffer(input.toString().replaceAll("[^a-z A-Z А-Я а-я]", ""));
out = new StringTokenizer(input.toString());
System.out.println("Форматированная строка - " + input.toString());
n = (out.countTokens());
for (i = 0; i <= n - 1; i++) {
tokenStr = new StringBuffer(out.nextToken());
aChar = (tokenStr.charAt(0));
if (tokenStr.length() > 1) {
if (Here is check for vowels) {
input.delete(input.indexOf(tokenStr.toString()),input.indexOf(tokenStr.toString())+ tokenStr.length() + 1);
}
} else {
input.delete(input.indexOf(tokenStr.toString()),input.indexOf(tokenStr.toString())+ tokenStr.length() + 1);
}
}