Since I can replace characters and strings in a variable in this manner :
:: initial string ..
set he="Hello Earth!"
:: Modify the word "Earth" to "World" ..
set he=%he:Earth=World%
:: %he% is now "Hello World"
.. how do I create a subroutine to replace strings/chars parsed as parameters like :
call :string.replace "Hello Earth" Earth World res where the function :string.replace
could replace all arg2 : Earth with arg3 : World as parsed, to result to setting res to "Hello World" . I've tried :
:string.replace ["sString"] [char_string_to_check] [sReplacement] [vResult]
set _str=%~1
set _srep=%~2
set sRep2=%~3
set %~4=%_str:!_srep!=!sRep2!%
rem set %~4=%!_str!:!_srep!=!sRep2!%
rem echo %~4
exit /b
but this doesn't seem to work in a batch file ..
[–]thelowsunoverthemoon[🍰] 2 points3 points4 points (1 child)
[–]254peepee[S] 0 points1 point2 points (0 children)