开发者

Different glob() results from local to server (Windows vs Linux)

I'd like to select only files that starts with a number or a letter:

$files = glob($xsl_dir_path . "/[^a-zA-Z0-9]*.xsl");
$files = array_map('basename', $files);

There are 3 files: a.xsl, b.xsl, _functions.xsl. I don't want to select _functions.xsl file.


*Edited (again) *

My bad, glob probably doesn't have regex as pattern match.
This won't work then: (?<![^/])[a-zA-Z0-9][^/]*\.xsl$
(just matches the filename.xsl preceeded with either a / or begining of string. )

However, for more control, use a glob '*.*' or something broad, then filter the list that glob produces with a regex like above. Its an extra step but will probably get uniform results across OS's


You are negating the class match, try:

$files = glob($xsl_dir_path . "/[a-zA-Z0-9]*.xsl");
$files = array_map('basename', $files);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜