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-25 08:48
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Can the delims= in for be a string? View 5,896 Replies 29
Floor 16 Posted 2007-10-19 19:46 ·  中国 浙江 绍兴 电信
中级用户
Credits 220
Posts 38
Joined 2004-08-12 00:00
21-year member
UID 30048
Gender Male
Status Offline
What is the difference between double exclamation marks and double percent signs?
I seem to see!n! in the do of for
Others like echo see %n%
Can you talk about this?
Floor 17 Posted 2007-10-19 19:47 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Floor 18 Posted 2007-10-19 20:56 ·  中国 河北 邯郸 电信
初级用户
Credits 30
Posts 12
Joined 2007-10-19 18:07
18-year member
UID 100183
Gender Male
Status Offline
tokens=1* What does this mean? I don't understand.
Floor 19 Posted 2008-01-25 00:38 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Still, the moderator is really brilliant, I admire it
Floor 20 Posted 2008-02-22 16:15 ·  中国 广东 汕头 潮阳区 电信
初级用户
Credits 53
Posts 20
Joined 2007-06-08 18:31
19-year member
UID 90697
Gender Male
Status Offline
Tried it myself, using word as a delimiter
@ echo off
set "a=333ps555psssword=123 456 789"
for /f "tokens=1* delims=word" %%i in ("%a%") do set b=%%i&set num=%%j
echo %b:~0,-4% %num%
pause
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
nanhui112 +1 2008-03-07 21:52
Floor 21 Posted 2008-03-07 21:52 ·  中国 广西 南宁 电信
初级用户
★★
Credits 127
Posts 59
Joined 2007-11-13 00:41
18-year member
UID 102491
Gender Female
Status Offline
This question is worth studying... That is, when delims = string, in what way it is split.
Floor 22 Posted 2008-03-08 14:24 ·  中国 广东 佛山 南海区 电信
初级用户
★★
Credits 131
Posts 72
Joined 2008-02-24 14:31
18-year member
UID 111317
Gender Male
Status Offline
Make good use of variables, use more "substitution"
Floor 23 Posted 2008-03-08 15:01 ·  中国 江苏 苏州 移动
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
When delims= is a string: For example: If the string is abc, then the delimiters that play a splitting role are a, b, c, ab, ac, bc, abc. Those who have studied permutations and combinations will know that no matter the length of the character, the number of possible delimiters is always: Cn1 + Cn(n-1) +... + Cnn, there are so many possibilities!
Floor 24 Posted 2008-03-08 22:56 ·  中国 广西 南宁 电信
初级用户
★★
Credits 127
Posts 59
Joined 2007-11-13 00:41
18-year member
UID 102491
Gender Female
Status Offline
Can only be subjectively considered. I mean, what are the characteristics of the string when it is being split, and in what way is it split? I also know from experiments. For example, if the string in delims= has uniqueness, it will use the entire string of letters as the delimiter; otherwise, it will use the first character as the delimiter. It's not accurate enough. Hope the experts can point out!
Floor 25 Posted 2008-03-09 15:41 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Originally posted by nanhui112 at 2008-3-8 10:56 PM:
Can only be subjectively considered this way. I mean, what characteristics the string has when it is being split, and in what way it is split.
I also know from experiments. For example, if the characters in delims= have uniqueness...


"delims=abcedef"

No matter what the situation is, the splitting of delims is using each character after the equal sign as the delimiter.

It just seems to use the entire string as the delimiter when it is said to be "unique".
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
nanhui112 +1 2008-03-10 21:26
Floor 26 Posted 2008-07-01 10:03 ·  中国 江西 南昌 电信
初级用户
Credits 48
Posts 19
Joined 2008-04-16 19:57
18-year member
UID 116095
Gender Male
Status Offline
After testing, it can also use a single Chinese character as a separator.
My understanding is that the separator is one byte

Originally posted by 26933062 at 2007-5-26 12:10 AM:
Oh. So that's the case. Does that mean it can only use a single letter or symbol as a separator?

[ Last edited by 26933062 on 2007-8-11 at 05:59 AM ]
Floor 27 Posted 2008-07-02 08:55 ·  中国 广西 玉林 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by wjmm at 2008-7-1 10:03:
After testing, it can also use a Chinese character as a separator,
My understanding is that the separator is one byte

As the 3rd floor said, it can only use a single letter or symbol as a separator, not a byte (one Chinese character is two bytes)
Floor 28 Posted 2008-07-02 15:16 ·  中国 江西 南昌 电信
初级用户
Credits 48
Posts 19
Joined 2008-04-16 19:57
18-year member
UID 116095
Gender Male
Status Offline
After testing, the delimiter can be a Chinese character
For example, there is a text file test.txt, and its content is as follows
-------------------------------------------------------------------------------
111111You2222222You3333333333You4444444
55555You66666You7777777777777777777You88888
9999You00000YouaaaaaaaaYoubbbbbb
---------------------------------------------------------------------------------

Batch processing code
@echo off
FOR /F "tokens=1,3,4 delims=You" %%a in (test.txt) do @echo %%a %%b %%c
pause

After executing this batch processing, it can be found that the Chinese character "You" can indeed be used as a delimiter

Byte"

Originally posted by zh159 at 2008-7-2 08:55 AM:

As the 3rd floor said, it can only be a single letter or symbol as a delimiter, not a byte (a Chinese character is two bytes)


[ Last edited by wjmm on 2008-7-3 at 11:30 AM ]
Floor 29 Posted 2009-10-29 12:16 ·  中国 福建 厦门 电信
初级用户
Credits 36
Posts 22
Joined 2009-09-12 00:31
16-year member
UID 151867
Gender Male
From 厦门
Status Offline
It's really good, I've learned something.
Floor 30 Posted 2009-10-31 15:26 ·  中国 四川 成都 电信
初级用户
★★
Credits 145
Posts 95
Joined 2008-04-12 16:29
18-year member
UID 115703
Gender Male
Status Offline
The brother upstairs has an amazing ability to dig up old posts... After reading for a long time, I just realized it's a post from two years ago... But it's also very classic
Forum Jump: