Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.44.0401301220460.2476-100000@gannet.stats>
Date: 2004-01-30T12:29:59Z
From: Brian Ripley
Subject: Doubt about pattern
In-Reply-To: <401C9D83@epostleser.online.no>

On Fri, 30 Jan 2004, Peter J. Acklam wrote:

> Marcelo Luiz de Laia wrote:
> 
> > 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")
> 
> That's not even a valid regular expression in most applications,
> but "dir" does allow it, for some reason.  Anyway, I think you

It is a valid regex in GNU's regex code as used by R, and all the GNU and
non-GNU applications I tried accepted it.  `*' matches itself when not
used as a repetition qualifier.  (I tried several greps, including those
claiming strict POSIX compliance.)

So, can you please list the `most applications' you tried or give a 
reference for your assertion?

> are mixing globs and regular expressions.  If "*.sens" is a glob,
> then it will find all files ending with ".sens", which is not
> the same as ".sens." which you said above.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595