std.regexp and std.file listdir

Unknown W. Brackets unknown at simplemachines.org
Wed Aug 23 23:20:18 PDT 2006


That's not a regular expression.  I think what you want is:

listdir(r"d:\tmp", RegExp(r"\.pdf$", "i"));

In a regular expression, "*" means "zero or more of the previous 
character.  So, "a*" would match "", "a", "aa", "aaaa", etc.

A dot means "any character except \n", so that wouldn't work like you 
expected either.  You have to escape it.

A $ means "end of line", so that means that the .pdf has to be at the 
end of the string, not just anywhere.

For more information, see:
http://www.digitalmars.com/ctg/regular.html

-[Unknown]


> I have this program:
> 
> import std.stdio;
> import std.file;
> import std.regexp;
> 
> int main(char[][] args)
> {
>   char[][] f = listdir(r"d:\tmp",RegExp(r"*.pdf","i"));
>   writefln(f.length);
>   return(0);
> }
> 
> When I run it, I get,
> 
> Error: *+? not allowed in atom
> 
> Why?
> 
> thanks,
> 
> josé
> 
> 



More information about the Digitalmars-d-learn mailing list