我正在使用PowerShell中的Ack版本2.04。我想在文本文件中搜索文本,例如"jsonClass":"Page"(包括引号)。
我似乎无法正确地进行引用和转义。
ack -c --match '"jsonClass":"Page"'
在PowerShell中它不起作用。我猜ack也会捕获单引号。
转义双引号会导致无效的正则表达式错误:
ack -c --match "\"jsonClass\":\"Page\""
Invalid regex '\':
Trailing \ in regex m/\/ at C:\CHOCOL~1\lib\ACK2~1.04\content\ack.pl line 315
我也尝试了字面量选项,但我认为ack将冒号解释为文件参数。
ack -c -Q --match "jsonClass":"Page"
ack.pl: :Page: No such file or directory
我错过了什么?
我正在使用PowerShell v2。