提取数字字段和大数加法-批处理应用

 setlocal enabledelayedexpansion

set "num1=qwer/asdf2/asd34f/1234567890123456/asdf/aaaa"

set "num2=aaaaa2/23456789012345678/asdfssasd/asdaa"

set "num1=%num1:/= %" & call :get_number !num1! & set "num1=!t!"

set "num2=%num2:/= %" & call :get_number !num2! & set "num2=!t!"

set "result="

:c_loop

set /a x=%num1:~-8%

set /a y=%num2:~-8%

set /a z=%x%+%y%

if defined flag set /a z=%z%+%flag%

set "flag=%z:~0,-8%" >>nul 2>>nul && set "z=%z:~-8%"

set "num1=%num1:~0,-8%"

set "num2=%num2:~0,-8%"

set "result=%z%%result%"

if not defined num1 if not defined num2 set "result=%flag%%result%" & goto :show

if not defined num1 set /a num1=0

if not defined num2 set /a num2=0

goto c_loop

:show

echo %result% & pause & goto :eof

:get_number

:loop

echo %1>> tmp.txt& shift

if not "%1"=="" goto :loop

for /f %%a in ('findstr /r "^[0-9][0-9]*$" tmp.txt') do set "t=%%a"

del tmp.txt


原文链接: http://blog.csdn.net/augusdi/article/details/5211215

你可能感兴趣的:(提取数字字段和大数加法-批处理应用)