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

Jerold Schulman

November 2, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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

set string=%string:= %

where 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 offif {%2}

{} @echo Syntax REWB String Newstring&goto :EOFsetlocalset string=%1:againset work=%string%for /f "Tokens=1* Delims

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



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like