I have a difficulty using grepl with regex.
Here is a small example:
I have a character vector:
text <- c(
"D_Purpose__Repairs" ,
"Age" ,
"F_Job"
)
And I want to select the words that start with D_ or F_. So I write:
grepl("\\>D_.+ | \\>F_.+", text)
grepl("\\D_.+ | \\F_.+", text)
grepl("\\^D_.+ | \\^F_.+", text)
However this returns:
[1] FALSE FALSE FALSE
Could you help me understand what I am doing wrong and how should I correct my code?
Your advice will be appreciated.