[R] Regular Expressionsionism

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Nov 29 18:41:50 CET 2002


"Derek Eder" <Derek.Eder at neuro.gu.se> writes:

> Isn't there a cryptic footnote somewhere in the blue book that describes regular expressions as "a funny little language ..." ?  Well, I'm not laughing!
> 
> I've googled and Man paged, but the GREP-style solution to the following problem still eludes me:
> 
> ... Using a regular expression in the "pattern" argument to list.files() to restrict the return to filenames which
> contain both "Elstim" and "post".  E.g.,
> 
> >list.files()
> ... 
> [133] "J30710_Control_msa_amplitude_5_25_s1-30w.pre"                                                    
> [134] "J30710_Elstim_msa_amplitude_5_25_s1-30w.post"                                                    
> [135] "J30710_Elstim_msa_amplitude_5_25_s1-30w.pre"                                                     
> [136] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.post"                                          
> [137] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.pre"                                           
> [138] "J30712_Elstim_msa_amplitude_5_25_s1-17_19-43_45_48w.post"                                        
>                                        
> I have not found the key to generating the logical AND equivalent of the "|" OR infix operator, a 
> proxy for the simpleton's dream:  my.list.files(pattern="*Elstim" & "*post") 

As long a you know the order, how about "Elstim.*post" ?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list