0
在批處理文件中,我想查看%1是否在一個集合中。批處理文件在字符串中查找字符串
例如,作爲替代
if %1 equ /? goto help
if /I %1 equ -? goto help
if /I %1 equ /help goto help
etc
現在看來似乎應該是簡單的,但我不能使它發揮作用。我嘗試了和沒有FOR循環和搜索:字符串。
在批處理文件中,我想查看%1是否在一個集合中。批處理文件在字符串中查找字符串
例如,作爲替代
if %1 equ /? goto help
if /I %1 equ -? goto help
if /I %1 equ /help goto help
etc
現在看來似乎應該是簡單的,但我不能使它發揮作用。我嘗試了和沒有FOR循環和搜索:字符串。
@echo off
setlocal enabledelayedexpansion
set "[email protected]/[email protected][email protected]/[email protected]"
if not "!helpoptions:@%[email protected]=!"=="%helpoptions%" goto help
goto :eof
:help
echo Help
將是一個選項,雖然不是一個非常漂亮的。
酷!有用。謝謝。 –
+1,使用%〜1從arg剝離潛在報價更安全 – dbenham
確實如此。人們也可以使用空格作爲分隔符,這會減少混亂,但可能會掩蓋一些非obviuos拼寫錯誤。 – Joey