string <- "apple,banana, cat, doll and donkey; fish,goat" trimws(gsub("(^|\\p{P})\\s*(.)", "\\1 \\U\\2", string, perl=T))