Skip to content
Prev 280661 / 398502 Next

regular expressions in R

To be correct for the regular expression, it should be:

dir(pattern = "\\.(txt|doc)$")

The form

dir(pattern="*.txt")

will match 'txt' appearing anywhere in the name; this looks like the
argument you would have used to "Sys.glob" which is a UNIX style file
name match and not a regular expression.  "." matches any character
unless you escape it to mean a 'period'.

On Wed, Dec 21, 2011 at 11:11 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote: