DIR and regular expressions

May 20, 2008
12,341
134
Syracuse, NY, USA
The regular expressing matching in DIR is **substring** matching, unlike wildcard matching.

And the matching is case-insensitive even though the file system is case-retentive and the regex is case-sensitive.

This example shows both.

Code:
v:\> dir /b ::"c.*\.bat"
a b c.bat
a b c.batx
c.batx

v:\> dir /b ::"c.*\.BAT"
a b c.bat
a b c.batx
c.batx

It would be nice if both changed in v11. IMHO the default should be matching on the whole name (like wildcards). I know I can force it with "^" and "$" but I think whole-name-matching is what's usually wanted (and the user can cforce substring matching in the regex if he wants). And since the file system (NTFS at least) is case-sensitive, allowing case-sensitive regex matching would simply give more power to the user; the user could defeat it in the regex.
 

Similar threads