Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

DIR and regular expressions

May
12,846
164
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

Back
Top