Hi. 1. A period in a pattern (as you wrote) means that you want to match *any* character. You need to escape the period, i.e. "\\.", or alternatively use the "[<set>]" indicator where <set> is all the characters you allow at that position, i.e. "[.]". (I prefer the latter because in is more readable and you don't have the \\ or \ problem when cut'n'pasting.)
2. To match the end of string use "$". Thus, you want to do files <- dir(pattern="*[.]sens$") To match filenames that ends with ".sens". This is how regexpr(), gsub() and friends all work. Cheers Henrik Bengtsson > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Marcelo Luiz de Laia > Sent: den 29 januari 2004 15:33 > To: [EMAIL PROTECTED] > Subject: [R] Doubt about pattern > > > Hi All, > > I have a very simple problem. I have several files in a same > directory. I would like to send for an object only the files > that finish in ".sens.". I execute the command below, > > files <- dir(pattern="*.sens") > > but it includes all of the files that have "sens", > independent of they be in the end or in the middle of the > name of the file. How could I solve this? I sought in the > html_help but I didn't find similar to this. > > My files > > "script_sens.txt", "Sen_155_01_R1.sens", > "Sen_155_01_R2.sens", "Sen_155_01_R3.sens", > "Sen_155_02_R1.sens", "Sen_155_02_R2.sens", > "Sen_155_02_R3.sens", "Sen_155_03_R1.sens", > "Sen_155_03_R2.sens", "Sen_155_03_R3.sens", "tome2sens_time1sens.txt" > > Tahnks very much > > -- > Marcelo Luiz de Laia, M.Sc. > Dep. de Tecnologia, Lab. Bioqu�mica e de Biologia Molecular > Universidade Estadual Paulista - UNESP Via de Acesso Prof. > Paulo Donato Castelane, Km 05 14.884-900 - Jaboticabal, SP, Brazil > PhoneFax: 16 3209-2675/2676/2677 R. 202/208/203 (trab.) > HomePhone: 16 3203 2328 - www.lbm.fcav.unesp.br - [EMAIL PROTECTED] > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailma> n/listinfo/r-help > PLEASE > do read the posting guide! > http://www.R-project.org/posting-guide.html > > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
