Koren Washington wrote:yes i did, i put s.split(s, '+');
Unlikely - that would have produced a compiler error. Perhaps you meant s.split(s, "+");?
Yeah, I know it sounds like I'm nitpicking. But the compiler is much less forgiving than I. It's important to pay attention to these details. One is a char, and one is a String. Completely different things, as far as the compiler is concerned.
Wouter Oet wrote:Look at the link I provided again because it is clearly explained what the regex is for.
Hmmm, I think it's not nearly as clear as one might like. While I agree that we should look first to the official documentation, I think that the Java docs on regular expressions are less than clear. They are precise, and correct, but not clear. To most of the human race, I think.
Christophe Verré wrote:And be careful that "+" is a special symbol used in regular expressions.
I think this is a particularly useful hint. The "+" sign has special meaning in regular expressions. If you want to refer to a character that is really a simple "+" sign, without any special meaning in the regex world, you probably need to escape it. Try "\\+" instead. And see Backslashes, escapes, and quoting for more explanation.
It's actually the old way of splitting strings, nothing ultimate here If you look carefully at the API, it says : "StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead. "