Split string into array of character strings

Matt picture Matt · Mar 8, 2011 · Viewed 322.1k times · Source

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

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

Answer

coberty picture coberty · Oct 19, 2012
"cat".split("(?!^)")

This will produce

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