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
  • 20,819
  • 23
  • 69
  • 107

0 Answers0