Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex: select string containing 2 specific words

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

aim would be to extract
drink_type_1_day1
drink_vol_1_day1

>Solution :

the regex pattern would be:

"^drink\\w+day1$"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading