这是我的问题。我做了一批,想从句子中移动单词之间的所有空格。我以一种方式做到了这一点。但我想将空间设置为变量,并在 set 命令中使用该变量。在检查了变量的定义,甚至对这个空间变量进行了很好的回响之后,我不能在最后一句中移动它。有人可以告诉我为什么吗?
@echo off
::why this doesnt work???
(set /p word2=i will make )<nul>textfile.txt
<nul (set/p word3=all strings be )>>textfile.txt
<nul (set/p word4=one longstring)>>textfile.txt
echo(
type textfile.txt
echo(
echo(
::seting space
set sp=a b
set sa=%sp:a=%
set space=%sa:b=%
if defined space (echo space is defined) else (echo space is not defined)
echo(
echo lets see:%space%%space%%space%something%space%something%space%%space%, ...works
echo(
set /p inputalltext=<textfile.txt
echo %inputalltext%...input from textfile
set noplaceforspace=%inputalltext: =% ...as you see as normal,no space
echo %noplaceforspace%
::so, problem starts here. why are here places if space is defined and good echoing
::of space variable??
setlocal enabledelayedexpansion
set nogoodresult=%inputalltext:!space!=%
echo %nogoodresult%%space%%space% here i dont want space between words
echo(
pause