2016-03-01 75 views
0
@echo off 
cd /D "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\" 
set ffile=%cd% 

findstr /m ^"homepage^":^"http://www.google.com/^" "%ffile%\Secure Preferences" 
if %errorlevel%==0 (
echo Ok 
)else (
    echo "Not Ok" 

) 
pause 

findstr当我搜索"homepage":"http://www.google.com/"不返回任何东西,但它工作时,我只搜索“主页” - 为什么?FINDSTR没有找到“主页”:“http://www.google.com/”

+0

那么你的主页没有设置为http://www.google.com – SomethingDark

+0

在^”homepage ^“中:^”google.com ^“返回”首页“:”google.com“但不工作 – checkmate

回答

1

findstr拥有“它自己的”转义字符规则(当然,它的正则表达式规则)(见findstr /?):

findstr /r /c:\"homepage\":\"http://www\.google\.com/\" "%ffile%\Secure Preferences" 

(点必须得逃脱,因为它的正则表达式的代码为“任何字符“)

+0

这是一个非常精简的正则表达式版本。 – SomethingDark

+1

@ SomethingDark你搜索的词是“基本”;) – Stephan

+0

是的,就是这样。这就像试图在OSX中使用bash。 – SomethingDark