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?

1
  • I have added an answer to the other question. The other question quoted the wrong part of the code. Commented Dec 15, 2014 at 4:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.