中国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-10-02 09:40
47,813 topics / 349,918 posts / today 0 new / 48,279 members
DOS批处理 & 脚本技术(批处理室) » Question: how to filter out percent signs on the command line
Printable Version  1,298 / 4
Floor1 kuixuan Posted 2010-07-01 15:49
新手上路 Posts 2 Credits 2
@echo off
set abc=123
set /p xx=enter:
set "xx=%xx:"=%"
echo %xx%
pause

The meaning of the code 【set "xx=%xx:"=%"】 is to filter out the 【quotation marks】
If you enter at : %abc%
the execution result of the code is to display ——

But now I need to filter out the 【percent signs】

That is, I want the execution result to become displaying on the screen, in other words, the percent signs in the previously entered line %abc% are deleted

So I modified the code like this —— set "xx=%xx:%=%"

But it gave an error, so how should I do it to filter out the 【percent signs】

I hope everyone can help me, thanks

[ Last edited by kuixuan on 2010-7-1 at 15:58 ]
Floor2 Lin7uan Posted 2010-07-02 01:00
初级用户 Posts 32 Credits 38
I'm a newbie too. Could you explain in more detail
set "xx=%xx:"=%"
this line?
Floor3 HAT Posted 2010-07-02 13:09
版主 Posts 5,017 Credits 9,023
String replacement feature of the set command
Floor4 pdanniel66 Posted 2010-07-03 05:19
初级用户 Posts 64 Credits 68
Test1 :
@echo off
set abc=123
set /p xx=enter:
set "xx=%xx:"=%"
echo %xx%
pause
The execution result is as follows:
enter:"aa
aa
Press any key to continue . . .
Test2 :
@echo off
set abc=123
set /p xx=enter:
set "xx=%xx:(=%"
echo %xx%
pause

The execution result is as follows:
enter: (aa
aa
Press any key to continue . . .
Floor5 kuixuan Posted 2010-07-03 23:46
新手上路 Posts 2 Credits 2
Seems like this has turned into a tutorial thread, but does nobody know how either?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023