JSI Tip 7402. How can I replace an equal sign (=) with a space character in a string variable?


The normal method for replacing a character with a space in a string variable is:

set string=%string:<character>= %

where <character> is the character, or string of characters, that you want to replace with a space character.

Because the equal sign (=) is the delimiter in this command, you cannot use it to replace an =.

I have scripted REWB.bat to replace =, or

, or =, etc, with a space.

The syntax for using REWB.bat is:

call rewb string newstring

where string is a constant or variable that contains one or more equal signs, and newstring is a call directed environment variable that will contain string with spaces instead of equal signs.

REWB.bat contains:

@echo off
if \{%2\}

\{\} @echo Syntax REWB String Newstring&goto :EOF setlocal set string=%1 :again set work=%string% for /f "Tokens=1* Delims

" %%a in ('@echo %string%') do if \{%%b\} NEQ \{\} set string=%%a %%b if \{%string%\} NEQ \{%work%\} goto again endlocal&set %2=%string%



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish