For loop value with spaces
Posted: 16 Sep 2024 17:20
Hi All -
I am reaching out to see if there is a cleaner way to prepare a passed value for use in a for loop. For instance, I'm passing this value to a function :
Then using it like this :
Is there a cleaner way?
I am reaching out to see if there is a cleaner way to prepare a passed value for use in a for loop. For instance, I'm passing this value to a function :
However, I need to iterate over both values, but space is considered a delimiter. So I am doing the following :CALL :TEST "ACR_US Bank_Regions,AR_EFT"
Code: Select all
SET "AUTOMATCH=!AUTOMATCH:, =,!" & REM Ensure no spaces after comma
SET "AUTOMATCH=!AUTOMATCH: =@!" & REM Temporarily replace spaces with @
SET AUTOMATCH="!AUTOMATCH:,=","!" & REM Wrap double quotes around each DLR
SET "AUTOMATCH=!AUTOMATCH:@= !" & REM Remove @ and replace with spac
Code: Select all
FOR %%A IN (!AUTOMATCH!,= !) DO ECHO %%A