Hi, > The command "dir( fold, pattern = "\.csv" )" gives back *all* the 3 files > With dir( fold, pattern = "\\.csv" ) I get back only VorlageTradefile.csv. > I don't understand this behaviour, IMHO the regex expression "\.csv" > becomes the string ".csv" and "\\.csv" becomes "\.csv". So the first > string should catch it. This is also consistent with the result when I > tried with the TRegExpr Tool. Could somebody explain what's going on > here?
Under R, for reasons I've never quite understood, "\\." evaluates to . (the double backslash is needed to match a single period) while "\." is the single-character wild card (which seems to be the same as ".") This is explained in ?strsplit but not in the help for other commands that use regex. > b) > I need to handle a copied windows file path. This is certainly often > asked but I didn't find a solution. If you mean you want to change the "\" to either "\\" or "/" I'm really not sure. On my linux system, it doesn't seem possible (which I'm sure is wrong). I'd try sub() or at worst a combination of strsplit() and paste(), except that: > test <- "D:\UebungenNDK\DataMining\DataMiningSeries.r" > test [1] "D:UebungenNDKDataMiningDataMiningSeries.r" Regular expressions under R have always perplexed me just a bit. When I've run into problems of this sort, I've always just processed the strings in vim or similar, rather than fight with R. I'm sure someone here understands them - hopeully we will both be enlightened. Sarah -- Sarah Goslee http://www.stringpage.com ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html