中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-26 01:19
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » How to implement variable substitution for variables?
Printable Version  3,267 / 4
Floor1 pigvip Posted 2006-10-11 06:58
新手上路 Posts 6 Credits 17
set a=123
set b=1234
How to replace the same parts in b with 0 using variable a?
Is it like this? How to write variable A?
echo %b:a=0%
Floor2 pengfei Posted 2006-10-11 08:46
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
The code is as follows:

Floor3 weilong888 Posted 2006-10-11 09:33
银牌会员 Posts 548 Credits 1,270
If
set a=123
set b=1234
And finally, how to write the code so that echo %b% displays 0004?
Floor4 namejm Posted 2006-10-11 09:38
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Originally posted by weilong888 at 2006-10-11 09:33:
If
set a=123
set b=1234
And finally, how to make echo %b% display 0004?
How should this code be written?

Change set "b=!b:%a%=0!" to set "b=!b:%a%=000!" to achieve it.
Floor5 3742668 Posted 2006-10-12 07:01
荣誉版主 Posts 718 Credits 2,013
It is also possible to use environment variables without enabling delay, but there are relatively large limitations:
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023