Split a string into a char array by a given delimiter