I have a string whose numbers I would like to replace with ***, then each group of asterisks with a single asterisk.
The first FOR is working as expected, then I have a problem replacing the *** with a single *, the delayed expansion does not work, you can see it by the ECHO command that I added after the IFs.
Code: Select all
@echo off
setlocal enableextensions enabledelayedexpansion
set end_of_line=0
set "result="
set string=120400082_V1_UTR_HN512_gfhtgnnrt
for /L %%A in (0,1,9) do set "var=!var:%%A=*!"
for /L %%A in (0,1,254) do if not !end_of_line! EQU 1 (call :parse %%A)
echo.!result!
pause
exit
:parse
if "!string:~%1,1!"=="" (set end_of_line=1 & goto :eof)
if "!string:~%1,2!"=="**" (set "result=!result!*") else (set "result=!result!!string:~%1,1!")
echo.###%1 ###!string:~%1,2!
pause
goto :eof
Thank you in advance.