I have column names that are something like this:
colnames <- c("a81", "b82", "a181", "b182")
I want to extract only columns that have either 81 or 82 at the end and before those numbers (81 and 82) there should be a letter. I want to use regex in grepl
and the expected output here is
TRUE TRUE FALSE FALSE
What I tried so far is
grepl("[:alpha:][81-82]$", colnames)
Unfortunately, the code returns FALSE
for all entries. What am I doing wrong?