R split on delimiter (split) keep the delimiter (split)

You can use "(?<=DELIMITERS)":

unlist(strsplit(x, "(?<=[?.!|])", perl=TRUE))

## [1] "What is this?"    "  It's an onion." "  What!"          " That's|"        
## [5] " Well Crazy.

Leave a Comment