Function to split string based on delimiter.