I am looking to find out which pattern is matched in a list of file names. I can find out if a match was found, but not which pattern was matched.
local_pattern <- data.frame(
condition = c("umhfl","dmhfl", "umhfr", "dmhfr", "shfr", "vshfr", "vshfl"),
filename = c("*Upward motion*HF*Left*.csv", "*Downward motion*HF*Left*.csv", "*UHFR*.csv", "*DHFR*.csv", "*SHFR*.csv", "*VSHFR*.csv", "*VSHFL*.csv")
)
## matching a sample file name
pattern_matched <- grep(paste(glob2rx(local_pattern[,2]), collapse = "|"), "./csv files/DHFR 2019-04-09 04.59 PM_001.csv", value = F)
What I would like to see is the pattern that was matched rather than simply a TRUE that a match was found.