in reply to seeing all files in a directory

The regular expression /^\.txt/ will match only filenames that start with ".txt", which doesn't seem to be what you want. This match fails for each file, giving you an empty list. Perhaps you want /\.txt$/?