Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30836
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2015-01-24 09:21 -0800 |
| Message-ID | <68b0cd7e-0dff-4e0f-9007-34ed5fd3d08f@googlegroups.com> (permalink) |
| Subject | remove question marks and exclamation points |
| From | elodie.gillain@gmail.com |
Hi everyone,
I wrote code to remove question marks and exclamation points from some text. However, one can find those in my output file. Interesting enough, the periods (full stops) were removed. Can anybody help me figure this out?
import java.util.Scanner;
public class TextTokenizer {
private Scanner scanner;
private String[] removableCharacters = { ".", "?", "!", ":", ";", "\"", "'" };
public TextTokenizer(char[] texts) {
scanner = new Scanner(new String(texts));
}
// Get the next word
public char[] nextWord() {
while(scanner.hasNext()) {
String word = scanner.next().trim();
if(word.isEmpty()) {
continue;
}
for(String character : removableCharacters) {
if(word.startsWith(character) || word.endsWith(character)) {
word = word.replace(character, "");
}
}
return word.toCharArray();
}
return null;
}
}
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
remove question marks and exclamation points elodie.gillain@gmail.com - 2015-01-24 09:21 -0800
Re: remove question marks and exclamation points Arne Vajhøj <arne@vajhoej.dk> - 2015-01-24 12:58 -0500
Re: remove question marks and exclamation points Arne Vajhøj <arne@vajhoej.dk> - 2015-01-24 12:59 -0500
Re: remove question marks and exclamation points Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-24 13:39 -0500
Re: remove question marks and exclamation points elodie.gillain@gmail.com - 2015-01-24 11:36 -0800
Re: remove question marks and exclamation points Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-24 20:13 -0500
csiph-web