mardi 12 juillet 2016

how to match the start and end of an expression with grep in R

I am trying to match the start and end of expressions with grep command, but I am not able to do that. for example consider the following expressions.

filenames <- c("S2abc.6h", "S2abc.4h", "S2abc.0h","S4abc.6h","S2xyz.6h")

I want to fins all the files starting with S2 and ending with 6h. I can select the files starting with S2 using:

grep("S2", filenames, value = TRUE)

But I am not able to use the wild cards with grep.

> grep("S2*6h", filenames, value = TRUE)

 character(0)

Aucun commentaire:

Enregistrer un commentaire