(directory-files) returns nil unexpectedly
The directory I keep my important files is stored as a string "/home/wdkrnls/Org/" in the variable org-dir
.
I want to li开发者_C百科st all the files in org-dir
that aren't backup files or org files (ie. that match ^[a-z0-9]+\.org$
). So I typed the following into *Scratch*:
;; (directory-files DIRECTORY &optional FULL MATCH NOSORT)
(directory-files org-dir '() "^[a-z0-9]+\.org$")
But this returns nil
. Even though ls
in /eshell/ gives me:
Notes.org Store Tasks.org
Can you explain why mine doesn't work?
The problem is your regexp, you want:
"^[a-zA-Z0-9]+\\.org$"
You forgot the capitalized version of A-Z
. And, you want a double \
so that the string reading leaves a \
in place to make the regexp treat the .
as a .
.
精彩评论