jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes StringTokenizer to remove 3 consecutive words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "StringTokenizer to remove 3 consecutive words" Watch "StringTokenizer to remove 3 consecutive words" New topic
Author

StringTokenizer to remove 3 consecutive words

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi guys,

look at my code below. my goal is to eliminate the words "on the moon" from the sentence: "there is a man on the moon with a dell computer";

I receive this result:

r is a a wi a DELL cpur




can any one help?

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ November 28, 2004: Message edited by: Dirk Schreckmann ]
Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
Tell me more about what this program is supposed to do:
Are you going to give it other phrases to remove from other
strings, or will you always be removing the words "on the moon"
from all input or what?
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
When you specify your delimiter as "on the moon" you are telling StringTokenizer that you want to use all of the seperate letters in that sentance as delimiters not the actual String itself. You are better off using the split command or something equivalent.



Hope this helps!
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
thank you Elouise for your prompt replt.

Basically, it suppose to remove only once the 3 word "on the moon" so the end result will be:

"there is a man with a DELL computer"

any suggestions?
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Barry Higgins

Perfect!!! thanks it works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StringTokenizer to remove 3 consecutive words
 
Similar Threads
Reversing a string
93%
91%
StringTokenizer, countTokens, nextToken???
Regarding String Tokenizer