Reputation: 9385
I'd like to know how I can use multiple delimiters with StringTokenizer in java.
For example one of these !,*,/,^
will occur as a delimiter. Also there will only be one at a time.
Upvotes: 15
Views: 37053
Reputation: 1135
You can use String.split() method because it takes regex as a parameter. You can specify Regex such that it can split the string based upon one of these deliminators.
Upvotes: 4
Reputation: 137322
Use the constructor with two arguments, where the second is the delimiters.
StringTokenizer tokenizer = new StringTokenizer(yourString, "!*^/");
Upvotes: 30