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-02 15:42
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: how to search for a specific string in a txt file View 5,039 Replies 20
Floor 16 Posted 2005-11-14 23:57 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 51
Posts 14
Joined 2005-11-06 20:02
20-year member
UID 44706
Gender Male
Status Offline
if "%a%" NEQ " ...

I'd like to ask, why does it have to be %a%, and why won't just one % work here? Also, what does NEQ mean?
Floor 17 Posted 2005-11-15 00:31 ·  中国 辽宁 锦州 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
Originally posted by malongxa at 2005-11-14 22:10:
Could the moderator and 无奈何, you two experts, explain in detail how to use "delims= token=2"? I still have no way to capture specific characters. Thanks again to both of you experts!!


delims= means splitting the text using as delimiters, and token=2 means starting from the second field.
See for /? for details


I'd like to ask, why does it have to be %a%, and why won't just one % work here? Also, what does NEQ mean?


%a% is an environment variable, not a loop variable.
For NEQ, see: if /?
Floor 18 Posted 2005-11-15 09:12 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re malongxa:

Under NT CMD there are two ways to “capture” specific characters (strings): one is to use for /f to analyze the characteristics of the boundaries before and after the string, which is suitable for extracting words or strings located between spaces or certain special characters; the other is to use set to analyze the row and column position of the string, which is suitable for extracting strings at known positions.

As for extracting “nate” as you said, you haven't considered by what method to extract it—whether it is the string in columns 28-32, or the string after Alter and before the space. This determines the difference in implementation.

[ Last edited by willsort on 2005-11-17 at 18:04 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 19 Posted 2005-11-16 10:41 ·  中国 陕西 西安 电信
初级用户
Credits 26
Posts 11
Joined 2005-11-09 14:40
20-year member
UID 44898
Status Offline
Thanks for the moderator's guidance. I want to learn both methods. Could you give me the solutions? Thanks again for the moderator's guidance.
Floor 20 Posted 2005-11-17 03:45 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Don't keep asking people to guide you, it has already been explained in great detail. Look at the results of these three commands, read them carefully, and try them slowly:
for /?
if /?
set /?

Only what you figure out yourself truly belongs to you. If the same command has been repeated to you N times and you still don't understand it, the reason is exactly that it was told to you by someone else.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 21 Posted 2005-11-17 09:23 ·  中国 陕西 西安 电信
初级用户
Credits 26
Posts 11
Joined 2005-11-09 14:40
20-year member
UID 44898
Status Offline
to:Climbing
Hello! As for these three commands, the purpose of my first post has already been achieved. Because I want to infer more from one example and study these three commands more deeply, I also tested many times by myself. It is precisely because there are some uses in /? that I don't understand that I asked the moderator to give his method as an example so I can learn. Please don't think I am someone who doesn't work hard. Thanks again to the moderator and 无奈何!
Forum Jump: