在findstr中转义引号 [英] escaping quotes in findstr

查看:243
本文介绍了在findstr中转义引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要对以下 findstr 命令进行哪些更改,以便返回精确使用 port的所有用法的列表: 在目录和子目录中包含的所有文件中?

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?

这是在Windows 8.1上,使用 cmd.exe 。 / p>

This is on windows 8.1 using cmd.exe.

推荐答案

您需要转义双引号,并且由于您的正则表达式使用空格,因此请使用 / c 切换以传递搜索字符串而不是用空格分隔的正则表达式:

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\" : " *

来自此处


多个正则表达式ns可以用空格分隔,只是
与分隔多个单词相同(假设您未使用/ C指定
文字搜索),但是如果正则表达式
本身包含,则此方法可能无用空格。

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.

这篇关于在findstr中转义引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆