Reputation: 11
I want to replace underscore(_) with space( ) form the string. But the batch I have written can't read the pipe(|) character. I tried putting (^) character before every PIPE but it did not work. Below is the script I tried.
@ECHO OFF
set string=Transaction_Type|Spend_Source_System|Event_ID
set string1=Transaction Type|Spend Source System|Event ID
set string=%string1%
ECHO %string%
pause
Upvotes: 1
Views: 90
Reputation: 82307
I recommend the first part of foxidrive's solution, but for the output, I would use delayed expansion, as you don't need quotes around the string anymore.
@ECHO OFF
setlocal EnableDelayedExpansion
set "string=Transaction_Type|Spend_Source_System|Event_ID"
set "string=!string:_= !"
echo !string!
Upvotes: 0
Reputation: 80033
@ECHO OFF
SETLOCAL
set "string=Transaction_Type^|Spend_Source_System^|Event_ID"
set "string1=Transaction Type^|Spend Source System^|Event ID"
set "string=%string1%"
ECHO %string%
endlocal
SETLOCAL
set "string=Transaction_Type^|Spend_Source_System^|Event_ID"
set "string=%string:_= %"
ECHO %string%
GOTO :EOF
Yeah - 'tis a little tricky...
Upvotes: 0
Reputation: 41244
Try this:
@ECHO OFF
set "string=Transaction_Type|Spend_Source_System|Event_ID"
set "string=%string:_= %"
ECHO "%string%"
pause
Upvotes: 2