[R] Regular Expressionsionism
jasont@indigoindustrial.co.nz
jasont at indigoindustrial.co.nz
Mon Dec 2 05:34:14 CET 2002
> "Derek Eder" <Derek.Eder at neuro.gu.se> writes:
..
> > ... 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")
In this case, the quick and (very) dirty method I'd also use is:
grep("Elstim",grep("post",list.files()))
generalising that via recursion to match an arbitrary number of REs
and "&" and "|" operators is left as an excercise....
Cheers
Jason
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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