我有以下向量:
X <- c("mama.log", "papa.log", "mimo.png", "mentor.log")
如何检索另一个仅包含以“m”开头并以“.log”结尾的元素的向量?
您可以使用grepl用正则表达式:
grepl
X[grepl("^m.*\\.log", X)]