aspose file tools
The moose likes Beginning Java and the fly likes StringTokenizer to remove 3 consecutive words Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: StringTokenizer to remove 3 consecutive words
 
Similar Threads
StringTokenizer, countTokens, nextToken???
Reversing a string
91%
Regarding String Tokenizer
93%