2

I found a neat way to extract all characters (as Strings) of a string:

String[] chars = "abc".split(""); // "a", "b", "c"

I expected to get a blank first term, but to my surprise it didn't split at start of input, even though a blank matches at start of input - ie between ^ and "a".

Conversely, a non-blank regex does match at start:

String[] chars = ";a;b;c".split(";"); // "", "a", "b", "c"

Why does a blank regex not split (ie match) at start of input?

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • I have added an answer to the other question. The other question quoted the wrong part of the code. – nhahtdh Dec 15 '14 at 04:23

0 Answers0