Hi all...i'm currently trying to manipulate strings from tokens. may i know how to eliminate a char from a token without splitting it?Below is some code that i tried.How can i eliminate a certain word after the tokens are set?
package autotextsum;
import java.util.*;
import java.util.StringTokenizer;
public class AutoTextSumm {
public static void main(String[] args) {
String s1;
String sDelim = ".?!";
StringTokenizer str1=new StringTokenizer("i like you very much.i do not hate you!i do.",sDelim);
while(str1.hasMoreTokens()) {
s1=str1.nextToken();
s1=s1.trim();
System.out.println(s1+"\n");
}
}
}
from the above code, the sentences would be split into 3 tokens,which are:
i like you very much
i do not hate you
i do
how do i eliminate the word "do" from each of the tokens?without affecting the number of tokens involved?the output should be like this
i like you very much
i not hate you
i
Thanks in advance for your time^^