We can replace strings in a batch file using the following command
set str="jump over the chair"
set str=%str:chair=table%
These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "chair" in the string with some variable and I don't know how to do it.
set word=table
set str="jump over the chair"
??
Any ideas?
You can use the following little trick:
The
call
there causes another layer of variable expansion, making it necessary to quote the original%
signs but it all works out in the end.This works fine
You can use !, but you must have the ENABLEDELAYEDEXPANSION switch set.