javaregexsplit

Split string into array of character strings


I need to split a String into an array of single character Strings.

Eg, splitting "cat" would give the array "c", "a", "t"


Solution

  • "cat".split("(?!^)")
    

    This will produce

    array ["c", "a", "t"]