string tokenizer question

I need to parse strings of the form "token A ops token B" where ops can be <, >, =, != and output "tokenA ops tokenB"....(remove spaces in the tokens).

I can use all the ops as delimiters (though I cant specify '!='), and get the tokens and remove the spaces in them. Using StringTokenizer, I doubt if I can know the exact delimiter I encountered so that I can rebuild the string quickly. Sure, I can do an indexOf() for each of the ops to find the one used in original string. But I am curious to know if there is any better approach to do this (doesnt have to be string tokenizer approach)?

[613 byte] By [jetAirwaysa] at [2007-11-26 15:39:49]
# 1
You can use the String.split() method with a regex that will match any of the operators. Note that this still won't return which operator was in the original string.
hunter9000a at 2007-7-8 21:58:14 > top of Java-index,Java Essentials,New To Java...
# 2
If the tokens always consist of "word characters" (letters, digits, and underscores) and the operators always consist of punctuation characters, you can do this: str = str.replaceAll("\\b\\s+\\b", "");
uncle_alicea at 2007-7-8 21:58:14 > top of Java-index,Java Essentials,New To Java...