What method should I follow in java to produce
\"WordWord\"
from
\"Word#$#$% Word 1234\"
The following answer is in more readable form
String inputString = "Word#$#$% Word 1234";
StringBuffer stringBuffer = new StringBuffer();
for (int k = 0; k < inputString.length(); k++) {
if (Character.isSpaceChar(inputString.charAt(k))) {
stringBuffer.append(" ");
} else {
if (Character.isLetter(inputString.charAt(k)))
stringBuffer.append(inputString.charAt(k));
}
}
System.out.println("Output : " + stringBuffer.toString());
}
Output : Word Word