[R] R2.1.0: Bug in list.files

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Thu May 12 12:05:43 CEST 2005


Uwe Ligges wrote:

> Please read about regular expressions (!!!) and try to understand that
> ".txt" also finds "Not_a_txt_file.xls" ....


  The confusion here is between regular expressions and wildcard 
expansion known as 'globbing'. The two things are very different, and 
use characters such as '*' '.' and '?' in different ways.

  There's added confusion when people come from a DOS background, where 
commands did their own thing when given '*' as parameter. The DOS command:

  RENAME *.FOO *.BAR

  did what seems obvious, renaming all the .FOO files to .BAR, but on a 
unix machine doing this with 'mv' can be destructive!

  In short (and slightly simplified), a '*' when expanded as a wildcard 
in a glob matches any string, whereas a '*' in a regular expression 
(regexp), matches the previous character 0 or more times. This is why 
"*.zip" is flagged as invalid now - there's no character before the "*".

  That should be enough clues to send you on your way.

  Baz




More information about the R-help mailing list