File Glob |
|
hello[a-z]??.*
against a filename. This page describes some approaches to support this in Lua.
Globs have had a number of syntaxes. See
FindFileFirst
/FindFileNext
Win32 API calls.)
The glob function implemented by Windows FindFileFirst
/FindFileNext
API calls can be especially counterintuitive and should sometimes be avoided (e.g. *.txt
may match both 1.txt
and 1.txt~
). So, wrapping these API calls in a Lua extension DLL may not be the most desirable approach.
The following approach converts a glob expression into a Lua pattern, which can then be used in Lua's pattern matching function. Roughly in concept, ignoring differences in syntax, globs are a subset of Lua patterns which are a subset of regular expressions. However, globs sometimes have some obscure rules and corner cases (see above) depending on chosen syntax.
source code: https://gist.github.com/1408288
Posix specifies that compilant systems provide a glob system call: see any such man page, e.g. http://linux.die.net/man/3/glob, for details.
The [luaposix] module interfaces to this library. --CharlesStewart?
See the [apr.fnmatch()] function in LuaApr, which wraps the APR's fnmatch function.
See also scite_Files in SciteExtMan. Also note [Perl glob].