0

I want to split a string by WHITE_SPACE, LPAREN or RPAREN.

I've tried this:

String st = "( a * b - (c * d )";
String[] subs = split.("(\\s+|\\(|\\))");

This kind of works, but it gives me empty strings in subs.

I expected to get "a", "*", "-", "c", "*", "d". But I actually got "", "", "a", "*", "-", "c", "*", "d". (basically, a bunch of extra empty strings)

What did I do wrong?

One Two Three
  • 22,327
  • 24
  • 73
  • 114

0 Answers0