我發現這個解決方案爲扭轉這一工作過的字符串,而沒有任何更多的出於某種原因:如何在批處理中反轉字符串?
setlocal enabledelayedexpansion
set num=0
:LOOP
call set tmpa=%%advanced:~%num%,1%%%
set /a num+=1
if not "%tmpa%" equ "" (
set string1=%tmpa%%string1%
goto LOOP
)
我,我收到的消息是:
The input line is too long.
The syntax of the command is incorrect.
我只需要扭轉字符串變量%advanced%
並將其輸出到%string1%
。
如果反轉字符串可以在一行中完成,那麼這對我正在處理的項目會非常有幫助。如果可以在沒有setlocal enabledelayedexpansion
的情況下完成,那會更有幫助,但我懷疑這是可能的。
多久你輸入的字符串?批量字符串只能有8192個字符長,如果您收到錯誤消息說您的輸入行太長,您將遇到問題。 – SomethingDark
你的字符串中可能有一些字符正在破壞代碼,如'%'或'!'或')'或'&'。 – SomethingDark
您的代碼啓用延遲擴展,但不會使用它。如果使用延遲擴展,使用雙倍百分比的CALL要慢得多。 – dbenham