escaping quotes in findstr

▼魔方 西西 提交于 2019-12-12 05:12:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!