在Windows批处理文件中运行以下代码时,除了包含星号的字符串之外,所有内容都会被删除.通过数字检查传递的参数(即echo(%~6)我可以看到星号 - 只有在传递给FOR循环时才会出现问题:
@echo off
setlocal enableextensions enabledelayedexpansion
call:Concat cmd "this is a demo" " of concat functionality." " Hopefully it will work;" " but it doesn't when I pass an" " * asterisk" " character"
echo !cmd!
@goto:end
@goto:eof
:Concat
::Concatenates a given list of strings without including their quotes
::1 - output variable
::2* - strings to concat
echo(%*
set /a xx=0
set Concat_tempFlag=0
set Concat_temp=
for %%A in (%*) do (
set /a xx=!xx!+1
echo …Run Code Online (Sandbox Code Playgroud) 我需要*从字符串替换字符,这是这样的:
*10.*31.**2.*65
我想*使用批处理脚本从此字符串中删除所有内容.