Search code examples
command-linecmdfindstr

Why "d:\0.0" doesn't substring of "D:\0.0" while using "findstr" command of Windows command prompt


I'm using "findstr" command with case-insensitive option (/I flag),
and I can't explain the results below.

echo "D:\0.0" | findstr /I "d:\0"

Output: "D:\0.0"

echo "D:\0.0" | findstr /I "d:\0.0"

Output:


why "d:\0.0" doesn't substring of "D:\0.0"?


Solution

  • Because you are searching for a regexp rather than a substring:

    >echo "D:\0.0" | findstr /I "D:\0.0"
    

    gives nothing either. You want to add the literal flag /l

    >echo "D:\0.0" | findstr /I /l "d:\0.0"
    

    gives:

    "D:\0.0"
    

    If you want to use the regexp, you need to escape the dot

    >echo "D:\0.0" | findstr /I "d:\0\.0"