library(stringr)x <- c("fair*", "beaut*")str_replace(x, "(.*)\\*$", "^\\1")sub("(.*)\\*$", "^\\1", x)
Standard input is empty
[1] "^fair" "^beaut" [1] "^fair" "^beaut"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!