If I have this string:
bb=c("\\dat\\Bjkjgf_Yloiut_dsezr_proj_111_999.txt","\\dat\\Bjkjgf_Yloezr_proj_111_999.txt")
I need to extract whatever between \\ and _proj
i can do this, but will work for one and not the other:
substr(bb, 1, 15)
the expected output
Bjkjgf_Yloiut_dsezr,Bjkjgf_Yloezr
>Solution :
Using gsub
gsub(".*\\\\|_proj.*", "", bb)
[1] "Bjkjgf_Yloiut_dsezr" "Bjkjgf_Yloezr"