Remove numbers from alphanumeric characters

r, regex

Solution

You can use `gsub` for this:

gsub('[[:digit:]]+', '', x)

or

gsub('[0-9]+', '', x)
# [1] "ACO"    "BCKDHB" "CD" 

Problem

I have a list of alphanumeric characters that looks like: ``` x <-c('ACO2', 'BCKDHB456', 'CD444') ``` I would like the following output: ``` x <-c('ACO', 'BCKDHB', 'CD') ```

Original source

Related problems