How do I remove all words that begin with a capital letter from a dataset?
For example:
d <- c("nice", "cat", "Cat", "Dog")
should result in c("nice", "cat")
(Yes, I looked online for a very long time before asking this question. I'm sure the answer is simple, but I cannot figure out the regex syntax for it.)
Find (grep
) words that start (^
) with upper-case letter ([A-Z]
), but return everything else (invert = TRUE
)
grep("^[A-Z]", c("nice", "cat", "Cat", "Dog"), invert = TRUE, value = TRUE)
# [1] "nice" "cat"