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-08-07 04:25
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about finding a string in VBS? View 660 Replies 4
Original Poster Posted 2007-12-29 12:16 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
I have a text file with two identical strings in it, for example "Beijing". Right now I want to find the second one—how should I write that? I know how to find both of them (I can do it in both VBS and P, but I don't want the first one)!! Also, if there are multiple ones (10 or more), and I only want the fifth one, how should that be written? (I can implement the above in P, but the text is too large, and one run takes 2.3 minutes, so the efficiency is low, that's why I want a VBS solution!!)
Floor 2 Posted 2007-12-29 12:21 ·  中国 广西 玉林 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Not on the same line?
Floor 3 Posted 2007-12-29 12:25 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
The principle is the same: set up a counter, and it should be doable with regular expressions.
Floor 4 Posted 2007-12-29 12:27 ·  中国 广西 玉林 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Right, you can count with something like If instr(read,str) > 0 Then i = i + 1
Floor 5 Posted 2007-12-29 12:27 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
Not on the same line!!!
Forum Jump: