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-06-30 16:33
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Regarding the issue of replacing special characters in text View 2,450 Replies 6
Original Poster Posted 2007-01-10 14:08 ·  中国 广东 深圳 腾讯云
初级用户
Credits 39
Posts 16
Joined 2006-12-06 14:21
19-year member
UID 72745
Gender Male
Status Offline
There is a text as follows:
http%3A%2F%2Fxxx.net%2Fxxx.htm

I want to convert all "%3A" to ":"
"%2F" to "/"
Get:http://xxx.net/xxx.htm

Refer to the posts in the forum
http://www.cn-dos.net/forum/viewthread.php?tid=26277&fpage=1&highlight=%E6%96%87%E6%9C%AC###
The replacement statement with set var=%var:%2F=/% failed

Ask if these are special characters??
Also read several posts on special character replacement:
http://www.cn-dos.net/forum/viewthread.php?tid=25692&fpage=1&highlight=%E6%9B%BF%E6%8D%A2
http://www.cn-dos.net/forum/viewthread.php?tid=22245&fpage=1&highlight=%E6%9B%BF%E6%8D%A2
The result is not understandable~!!
Ask how to write it?
原谅我的无知
Floor 2 Posted 2007-01-10 22:53 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
You can write it like this in VBS

A = REPLACE("http%3A%2F%2Fxxx.net%2Fxxx.htm", "%3A", ":")
MSGBOX REPLACE(A, "%2F", "/")
Floor 3 Posted 2007-01-10 23:41 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Batch code is as follows:
@echo off&setlocal enabledelayedexpansion
for /f %%i in (1.txt) do set var=%%i
set var=!var:%%3A=:!
set var=!var:%%2F=/!
echo !var!
pause


[ Last edited by ccwan on 2007-1-10 at 11:57 PM ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 4 Posted 2007-01-11 01:11 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Floor 5 Posted 2007-01-11 01:13 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Hehe, why doesn't vkill just write out the code?
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2007-01-12 08:23 ·  中国 北京 北京京宽网络科技有限公司
初级用户
Credits 39
Posts 16
Joined 2006-12-06 14:21
19-year member
UID 72745
Gender Male
Status Offline
Originally posted by ccwan at 2007-1-10 10:41 AM:
Batch code is as follows:
@echo off&setlocal enabledelayedexpansion
for /f %%i in (1.txt) do set var=%%i
set var=!var:%%3A=:!
set var=!var:%%2F=/!
echo !var!
pause


[ Last ...


Thanks!!
原谅我的无知
Floor 7 Posted 2007-01-12 08:30 ·  中国 北京 北京京宽网络科技有限公司
初级用户
Credits 39
Posts 16
Joined 2006-12-06 14:21
19-year member
UID 72745
Gender Male
Status Offline
Originally posted by ccwan at 2007-1-10 12:13 PM:
Hehe, why doesn't vkill just write out the code?



I posted a thread the other day.. didn't have time to come up and check..
Thanks for the advice....:)

Regarding external commands like sed...
Because using BAT was originally for convenience.. Windows comes with it.. every machine has it..
But switching to something else, maybe more powerful.. but still loses the original intention of convenience.. (because I'm not a DOS fan)

But still thanks to Brother vkill for the attention
原谅我的无知
Forum Jump: