I am trying to construct a regex expression in R as part of pivot_longer(cols = matches()
to select columns that start with drink and end with day1.
e.g.
drink_type_1_day1
drink_vol_1_day1
drink_type_1_day2
drink_vol_1_day2
currently I have ^drink
however I can’t combine it with $day1
aim would be to extract
drink_type_1_day1
drink_vol_1_day1
>Solution :
the regex pattern would be:
"^drink\\w+day1$"