Cathrin, Cathryn, Cathrinn, Cathrynn, Cathrine, Cathryne, Cathrinne, Cathrynne
so I tried this but I am not sure how to proceed.
reg_ex1 = c('Cathrin', 'Cathryn', 'Cathrinn', 'Cathrynn', 'Cathrine', 'Cathryne', 'Cathrinne', 'Cathrynne' )
Cathr(in|yn)(e|ne|n)
CodePudding user response:
You were very close, make the second part of the regex (e|ne|n
) optional (?
).
grepl('Cathr(in|yn)(e|ne|n)?', reg_ex1)
#[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE