str_split and str_trim and simplify in R

Viewed 2064

This is for people using stringr in R.

I want to split a name into first and trim any stray spaces.

> str_trim(str_split(c("John Smith"),"\\s+"))
[1] "c(\"John\", \"Smith\")"

Where are all the escaped "s coming from?

I was expecting c("John","Smith")

2 Answers
Related