Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with testing the last token

 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone can someone help me please?
i want to be able to test the last token, to see if it is a delimeter or a string. if the last token is a delimeter (comma), i want an empty string to be put in my vector.
i already have tested to see if between two delimeters is a empty string or not and that works fine, but i am a bit stuck on how to see if the last token is a delimeter or not.
could someone please give me some ideas or solutions.
thanks
ben
 
Sayed Ibrahim Hashimi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ben riches:
hello everyone can someone help me please?
i want to be able to test the last token, to see if it is a delimeter or a string. if the last token is a delimeter (comma), i want an empty string to be put in my vector.
i already have tested to see if between two delimeters is a empty string or not and that works fine, but i am a bit stuck on how to see if the last token is a delimeter or not.
could someone please give me some ideas or solutions.
thanks
ben

Can't you just hold a copy of the last token that you used and iterate through all the tokens and at the end your copy will point the last one so check to see if its a delimiter or a string.
Example:

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic