windows - How to split a number into individual digits in CMD/Batch -


i want split numbers individual digits , store them variables using cmd/batch on windows. example, number '38' should stored '3' in var1 , '8' in var2.

this current take on issue:

@echo off set number=38 /f "tokens=1,2 delims=0123456789" %%a in ("%number%") (call :varset %%a %%b) echo %number% has fallowing digits: echo 1st digit: %var1% echo 2nd digit: %var2% pause exit /b 0  :varset set var1=%1 set var2=%2 goto:eof 

i want output be:

echo 38 has fallowing digits: echo 1st digit: 3 echo 2nd digit: 8 

but get:

echo 38 has fallowing digits: echo 1st digit: echo off. echo 2nd digit: echo off. 

the problem seem fact use '0123456789' delimiter. perhaps not doable @ using for-loop?

edit: typos

just hell of it:

@echo off setlocal enabledelayedexpansion set "i=0" /f delims^=^ eol^= %%a in ('"cmd/u/cecho %*|find /v """') (set/a i+=1     set "var[!i!]=%%a") set var[ timeout -1 

just run file.cmd 5678 file.cmd saved name of script , 5678 alphanumeric string split individual variables.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -