Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.33.0104261247230.182756-100000@homer30.u.washington.edu>
Date: 2001-04-26T19:52:57Z
From: Thomas Lumley
Subject: list.files wildcard
In-Reply-To: <Pine.GSO.4.04.10104261526530.22179-100000@julius.ling.ohio-state.edu>

On Thu, 26 Apr 2001, David White wrote:

>
> Hello all,
>
> I have a simple question:
>
> I have filenames that look like these:
>  "n031ku09.10msmeanc" "n031ku10.10msmeanc" "n031ku11.10msmeanc"
> [22] "n031ku12.10msmeanc" "n031ti01.10msmeanc" "n031ti02.10msmeanc"
>
> I also have a set of the same without the "c" at the end.
>
> When I run list.files(".", pattern="*ku[01-30].meanc"), I get no result.
> I'm guessing that what I have here a problem with "." as a wildcard or
> metacharacter. How do I get it to read as a literal in that expression?
>

No, that's not the problem. If you do
  a<-c("n031ku09.10msmeanc", "n031ku10.10msmeanc", "n031ku11.10msmeanc")
  grep("*ku[01-30].meanc",a)
you still get no files, so the problem is with the regular expression.

[01-30] doesn't mean numbers between 01 and 30. It means a single
character that is 0, between 1 and 3, or zero

You can get nearly the right thing with
   "*ku[0-3][0-9].10msmeanc"
which matches numbers from 01 to 39


	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._