简体   繁体   English

在findstr中转义引号

[英]escaping quotes in findstr

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? 为了返回目录和子目录中包含的所有文件中确切短语"port" : "的所有使用的列表,需要对以下findstr命令进行哪些更改?

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 . 在Windows 8.1上使用cmd.exe

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: 您需要转义双引号,并且由于您的正则表达式使用空格,请使用/c开关传递搜索字符串而不是使用空格分隔的正则表达式:

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. 多个正则表达式可以用空格分隔,就像分隔多个单词一样(假设您未使用/ C指定文字搜索),但是如果正则表达式本身包含空格,则这可能没有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM