|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『楼 主』:
for中的delims=可以是字符窜吗?
使用 LLM 解释/回答一下
我想用for命令这样行吗?
@echo off
set "var=333ps555psssword=123 456 789"
for /f "tokens=1* delims=psssword" %%i in ("%var%") do set str=%%i&set num=%%j
echo %str% %num%
pause
我的本意是
设 str=333ps555
num==123 456 789
可结果却是
str=333
num=555psssword=123 456 789
为什么我运行的结果是以 p 或 s 为分隔符的啊?而不是以psssword为分隔符?
Last edited by 26933062 on 2007-8-13 at 12:13 AM ]
Can I do this with the for command like this?
@echo off
set "var=333ps555psssword=123 456 789"
for /f "tokens=1* delims=psssword" %%i in ("%var%") do set str=%%i&set num=%%j
echo %str% %num%
pause
My original intention was
Set str=333ps555
num==123 456 789
But the result is
str=333
num=555psssword=123 456 789
Why does the result of my run use p or s as the delimiter instead of psssword?
Last edited by 26933062 on 2007-8-13 at 12:13 AM ]
|

致精致简! |
|
2007-5-25 23:42 |
|
|
bjsh
银牌会员
    
积分 2000
发帖 621
注册 2007-1-1
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
delims=psssword
将会以这些字母做为分割符;不只是p和s,w,o,r,d也将被用做分割符;
delims不能将字符串做为分割符;
delims=psssword
Will use these letters as delimiters; not just p and s, w, o, r, d will also be used as delimiters;
delims cannot be used as delimiters for the string;
|
|
2007-5-26 00:07 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
哦.原来这样,就是说只能以一个单一的字母或符号作分隔符 是吗?
Last edited by 26933062 on 2007-8-11 at 05:59 AM ]
Oh. So that's it, it means it can only use a single letter or symbol as a separator, right?
Last edited by 26933062 on 2007-8-11 at 05:59 AM ]
|

致精致简! |
|
2007-5-26 00:10 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2007-5-26 00:10:
哦.原来这样,就是说只能以一个单一的字母或符号作分隔符 是吗?
for 命令的 delims 选项是这样的。
要以 psssword 这个字串为分隔符,我仅仅知道 gawk 这个工具可以,在论坛搜索一下可以找到下载地址。
C:\>echo 333ps555psssword=123 456 789|gawk "BEGIN{FS=\"psssword\"}{str=$1;num=$2;print \"str=\"str\"\nnum=\"num}"
str=333ps555
num==123 456 789
Originally posted by 26933062 at 2007-5-26 00:10:
Oh. So that's it, it means it can only use a single letter or symbol as a delimiter, right?
This is how the delims option of the for command works.
To use the string "psssword" as a delimiter, I only know that the gawk tool can do it. You can find the download address by searching in the forum.
C:\>echo 333ps555psssword=123 456 789|gawk "BEGIN{FS=\"psssword\"}{str=$1;num=$2;print \"str=\"str\"\nnum=\"num}"
str=333ps555
num==123 456 789
|
|
2007-5-26 00:36 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
哦.谢谢了,用工具就不用了,......
主要是学批处理,,,,
Oh. Thanks, but I won't use tools,...
Mainly learning batch processing,...
|
|
2007-5-26 00:40 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2007-5-26 00:40:
哦.谢谢了,用工具就不用了,......
主要是学批处理,,,,
有时用一些工具可以解决很多问题的,但我不强求。
虽然 for 命令的 delims 选项不支持字串的分割,但是如果想达到你的目的,换一个思路或许也可以:
@echo off
set "var=333ps555psssword=123 456 789"
set "var=%var:psssword=_%"
for /f "tokens=1* delims=_" %%a in ("%var%") do set str=%%a&set num=%%b
echo str=%str%
echo num=%num%
pause
Originally posted by 26933062 at 2007-5-26 00:40:
Oh. Thanks. I don't need to use tools,......
Mainly learning batch processing,,,,
Sometimes using some tools can solve many problems, but I don't force it.
Although the delims option of the for command doesn't support string splitting, if you want to achieve your goal, changing the idea might also work:
@echo off
set "var=333ps555psssword=123 456 789"
set "var=%var:psssword=_%"
for /f "tokens=1* delims=_" %%a in ("%var%") do set str=%%a&set num=%%b
echo str=%str%
echo num=%num%
pause
|
|
2007-5-26 00:49 |
|
|
sunshine217
新手上路

积分 0
发帖 1
注册 2007-6-1
状态 离线
|
|
2007-6-2 21:25 |
|
|
baikaifang
初级用户
 
积分 68
发帖 32
注册 2006-10-20
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
各位大侠们呀,为什么都不写命令的注释啊,让我们这些菜鸟看了一头雾水呀,里面用到的一些怪子符,网上也找不到用法啊.结果看了等于没看.不知道每条命令具体的含义,遇到别的问题的时候就不能举一反三.唉
Dear all experts, why don't you write comments for the commands? It makes us noobs confused. Some strange characters used in them can't be found online for their usage. As a result, reading them is like not reading. I don't know the specific meaning of each command, and then I can't apply what I've learned to other problems.
|
|
2007-6-2 21:53 |
|
|
qingfushuan
高级用户
   
积分 502
发帖 327
注册 2006-12-30
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by baikaifang at 2007-6-2 09:53 PM:
各位大侠们呀,为什么都不写命令的注释啊,让我们这些菜鸟看了一头雾水呀,里面用到的一些怪子符,网上也找不到用法啊.结果看了等于没看.不知道每条命令具体的含义,遇到别的问题的时候就不能举一反三.唉
雾里看花啊,3D图片就是这样看出来的,坚持看上3个月,你就清楚了,我就是去年12
月开始雾里看花的啊,现在看3D图片了
Originally posted by baikaifang at 2007-6-2 09:53 PM:
Dear experts, why don't you write comments for the commands? It makes us noobs confused. Some strange characters used in them can't be found online. As a result, reading them is like not reading. I don't know the specific meaning of each command, and I can't draw inferences from one instance when encountering other problems. Alas
It's like looking at things through a mist! 3D pictures are seen like that. If you persist in looking for three months, you'll understand. I started looking through a mist last December, and now I can see 3D pictures.
|
|
2007-6-4 11:57 |
|
|
step2step
初级用户
 
积分 44
发帖 25
注册 2007-3-25
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
前面看懂了,后面是天书
The first part was understood, but the latter part is like天书.
|
|
2007-6-4 15:05 |
|
|
huyujuen121
新手上路

积分 9
发帖 5
注册 2007-8-2
状态 离线
|
|
2007-8-3 08:28 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
3D图片几秒就可以了啊
A few seconds for the 3D picture is okay.
|
|
2007-8-3 10:12 |
|
|
sting
初级用户
 
积分 45
发帖 23
注册 2007-7-31
状态 离线
|
|
2007-8-8 10:02 |
|
|
1112yuhua
初级用户
 
积分 106
发帖 44
注册 2007-6-1
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
lxmxn版主果然高,把password用_来替换了。
Moderator lxmxn is really excellent, replacing password with _.
|
|
2007-8-16 01:26 |
|
|
liuyun20
初级用户
 
积分 36
发帖 14
注册 2007-3-4
状态 离线
|
『第 15 楼』:
顶了!!
使用 LLM 解释/回答一下
set "var=%var:psssword=_%",把password用_来替换了.
学习了.
set "var=%var:psssword=_%", replaced password with _.
Learned.
|
|
2007-10-18 22:56 |
|