string_1 = "[1] \" .. ..$ : chr [1, 1] \\\"DM_4CRSOL\\\"\""
How to extract 'DM_4CRSOL' from string_1 using regex in R?
Thanks in advance.
I like to expand on romles answer:
#install.packages("stringi") library(stringi) string_1 = "[1] \" .. ..$ : chr [1, 1] \\\"DM_4CRSOL\\\"\"" stri_extract(string_1, regex = '(?<=\\\\").*(?=\\\\")')
gives
[1] "DM_4CRSOL"
This does the task: stringi::stri_extract(string_1, regex = '(?<=\\\\").*(?=\\\\")')
stringi::stri_extract(string_1, regex = '(?<=\\\\").*(?=\\\\")')