I have a character vector containing variable names such as x <- c("AB.38.2", "GF.40.4", "ABC.34.2")
. I want to extract the letters so that I have a character vector now containing only the letters e.g. c("AB", "GF", "ABC")
.
Because the number of letters varies, I cannot use substring
to specify the first and last characters.
How can I go about this?
you can try