I have the following vector:
X <- c(\"mama.log\", \"papa.log\", \"mimo.png\", \"mentor.log\")
How do I retrieve another vector that only
Try this:
grep("^m.*[.]log$", X, value = TRUE) ## [1] "mama.log" "mentor.log"
A variation of this is to use a glob rather than a regular expression:
grep(glob2rx("m*.log"), X, value = TRUE) ## [1] "mama.log" "mentor.log"