问题
What changes need to be made to the following findstr
command in order to return a list of all the uses of the exact phrase "port" : "
in all the files contained in the directory and subdirectories?
findstr /I "port" : " *
Obviously, escaping the quotes is necessary, but what specific syntax is required to escape the quotes while still getting the expression to return the expected values?
This is on windows 8.1 using cmd.exe
.
回答1:
you need to escape the double quote, and since your regular expression uses spaces, use the /c
switch to pass a search string instead of space separated regexes:
findstr /I /c:"port\" : " *
from here:
multiple Regular Expressions can be separated with spaces, just the same as separating multiple words (assuming you have not specified a literal search with /C) but this might not be useful if the regex itself contains spaces.
来源:https://stackoverflow.com/questions/37262364/escaping-quotes-in-findstr