August 24, 2006 std.regexp and std.file listdir | ||||
---|---|---|---|---|
| ||||
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é |
August 24, 2006 Re: std.regexp and std.file listdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | 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é > > |
Copyright © 1999-2021 by the D Language Foundation