Results 1 to 6 of 6
Thread: Java Tokenizer
- 02-28-2011, 07:47 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 24
- Rep Power
- 0
- 02-28-2011, 07:49 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
using String.split() is usually better, look it up.
It's pretty simple thought, what items do you want to remove from the string?
- 02-28-2011, 07:53 PM #3
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
But the Tokenizer is a legacy class, see : StringTokenizer (Java Platform SE 6)Java Code:StringTokenizer tokenizer = new StringTokenizer(s, "-+");
Java Code:String s = "15A-45B+25C-56H+91V"; for (String string : s.split("[-+]")) { System.out.println(string); }
- 02-28-2011, 07:56 PM #4
Member
- Join Date
- Mar 2010
- Posts
- 24
- Rep Power
- 0
Imagine the sentence that i gave you as an equation! I want to tokenize the equation to its vars as in the example...
- 02-28-2011, 07:59 PM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I understood how to do it, a poster gave you the code which is frowned upon, however, he did show you how to do it. I was intending to get you to explain in more detail what you wanted to do, which would make doing this much easier. If for example you responded and said "I want to split the input into tokens from between +'s and -'s" You would be halfway there. From there you would simply have to look up what kind of arguments the constructor to the tokenizer class takes.
- 02-28-2011, 08:32 PM #6
Member
- Join Date
- Feb 2011
- Posts
- 63
- Rep Power
- 0
Similar Threads
-
String Tokenizer help
By GreenTea in forum New To JavaReplies: 4Last Post: 10-30-2010, 02:44 AM -
String Tokenizer
By sumaih in forum Java GamingReplies: 2Last Post: 08-21-2010, 03:23 PM -
Java String Tokenizer
By zaz_rin in forum Forum LobbyReplies: 2Last Post: 03-17-2010, 04:17 AM -
java tokenizer
By mia69 in forum New To JavaReplies: 3Last Post: 02-06-2010, 06:41 PM -
string tokenizer
By twinytwo in forum New To JavaReplies: 2Last Post: 03-26-2009, 02:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks