Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StringTokenizer to remove 3 consecutive words

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry Higgins

Perfect!!! thanks it works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic