The perl()
function is deprecated in the latest version of stringr in favor of regex()
. However, I don't seem to be able to replicate the earlier behavior.
To capitalize the first letter of a vector of strings, this used to work:
name <- c("jim", "john", "bill")
str_replace(name, perl("^(.)"), "\\U\\1")
However, this no longer works:
str_replace(name, regex("^(.)"), "\\U\\1")
But using base R works:
gsub("^(.)", "\\U\\1", name, perl=TRUE)
Is there still a way to do this with the stringr package?