ababab
2010-06-25 12:14:28 UTC
I am trying to build a word dictionary sort of.
I need to scan the words from an input file and use those words.
But I also need to strip out the non-characters like comma, dot, semicolon, colon, dash and single and double-quote signs.
So how do u use the Scanner.useDelimiter() to treat those signs like regular whitespaces ?
The java site : http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html has code like this:
String input = "ken fish great fish manfish loves-fish";
Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*");
System.out.println(s.next());
System.out.println(s.next());
System.out.println(s.next());
System.out.println(s.next());
The output is :
ken
great
man
loves-
that treats "fish" as another delimiter, but the \\s* confuses me..
is that escape character for whitespace ? or what is that for ?
------------------------------------------
Is there any method in String class that I can use to strip out strings from a specific character
like I want to convert "don't" into "dont" or "done." into "done".
Thanks for your help.