Being a Java Newbie, I am struggling with String.split
. Trying to tokenism the following string
"(3,3,{S,W,P},{P,W,P},{P,P,P}),(1,2,{S,E}),(2,1,{{S},{E}})"
with the regex pattern "\\{|\\(|\\}|\\)|\\s|,"
using String.split.
Unfortunately, it also returns empty Strings where ever match occurs which I want to suppress similar to what StringSplitOptions.RemoveEmptyEntries
does in C#.
On the contrary using StringTokenizer
works quite well, but being deprecated I am trying to avoid it. To make my question clear I am trying an equivalent behavior with String.split
as I would get using the following Tokenizer
new StringTokenizer(input2, "{},() \t")
Please suggest, how should I proceed.