China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 08:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: how to filter out percent signs on the command line View 1,168 Replies 4
Original Poster Posted 2010-07-01 15:49 ·  中国 广东 韶关 电信
新手上路
Credits 2
Posts 2
Joined 2010-03-20 23:09
16-year member
UID 162663
Gender Male
Status Offline
@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 ]
Floor 2 Posted 2010-07-02 01:00 ·  中国 广东 深圳 电信
初级用户
Credits 38
Posts 32
Joined 2010-04-07 22:43
16-year member
UID 164009
Gender Male
Status Offline
I'm a newbie too. Could you explain in more detail
set "xx=%xx:"=%"
this line?
Floor 3 Posted 2010-07-02 13:09 ·  新加坡
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
String replacement feature of the set command
Floor 4 Posted 2010-07-03 05:19 ·  中国 台湾 台湾宽频通讯顾问股份有限公司
初级用户
★★
Credits 68
Posts 64
Joined 2009-05-23 20:43
17-year member
UID 145803
Gender Male
Status Offline
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 . . .
Floor 5 Posted 2010-07-03 23:46 ·  中国 广东 韶关 电信
新手上路
Credits 2
Posts 2
Joined 2010-03-20 23:09
16-year member
UID 162663
Gender Male
Status Offline
Seems like this has turned into a tutorial thread, but does nobody know how either?
Forum Jump: