1<%
2function GetPos(start,word)
3 dim i,IntIndex,MaxIndex
4 dim flag
5 flag = 1
6 MaxIndex = 0
7 for i=0 to ubound(ArrWord)
8 if i<>cint(word) then
9 IntIndex = Instr(start+len(ArrWord(word)),StrObj,ArrWord(i))
10 if IntIndex>0 then
11 flag = flag + 1
12 'response.write flag & ":" & i & "<br>"
13 if MaxIndex<(IntIndex+len(ArrWord(i))) then
14 MaxIndex = IntIndex+len(ArrWord(i))
15 end if
16 end if
17 end if
18 next
19 if flag = ubound(ArrWord)+1 then
20 GetPos = "(" & start & "," & cstr(MaxIndex-start) & ")"
21 else
22 GetPos = "(1,2,3)"
23 end if
24
25end function
26
27function GetNearest()
28 dim i,StrResult,IntIndex,Seq,StrResult1
29 StrResult = ","
30 StrResult1 = ","
31 for i = 0 to ubound(ArrWord)
32 Seq = 1
33 IntIndex = Instr(Seq,StrObj,ArrWord(i))
34 do until IntIndex<1
35 StrResult = StrResult & IntIndex & ","
36 StrResult1 = StrResult1 & i & ","
37 Seq = IntIndex + Len(ArrWord(i))
38 IntIndex = Instr(Seq,StrObj,ArrWord(i))
39 loop
40 next
41 StrResult = left(StrResult,len(StrResult)-1)
42 StrResult = right(StrResult,len(StrResult)-1)
43 StrResult1 = left(StrResult1,len(StrResult1)-1)
44 StrResult1 = right(StrResult1,len(StrResult1)-1)
45 GetNearest = StrResult & "|" & StrResult1
46end function
47
48dim StrObj,ArrWord,ArrDotList,ArrWordList,ArrAll,i,ArrLen,StrLenList
49'StrObj="wer张三色单峰驼retert李四李四李四sdf张三色单峰驼rete34王五53赵六543543rt李四sdfwe"
50StrObj="aaa张三bbbb李四李四李四ccc张三dddddddd王五e赵六f李四ggg王五热土hhhhhhh赵六"
51ArrWord = Array("张三","李四","王五","赵六","刘七")
52ArrAll = split(GetNearest,"|")
53ArrDotList = split(ArrAll(0),",")
54ArrWordList = split(ArrAll(1),",")
55StrLenList = ""
56
57for i=0 to ubound(ArrDotList)
58 StrLenList = StrLenList & GetPos(ArrDotList(i),ArrWordList(i))
59next
60'response.write StrLenList & "<br>"
61StrLenList = left(StrLenList,len(StrLenList)-1)
62StrLenList = right(StrLenList,len(StrLenList)-1)
63
64ArrLen = split(StrLenList,")(")
65
66dim MinMarginId,MinMargin,ArrTemp,MinMarginStart
67MinMargin = 100000
68for i=0 to ubound(ArrLen)
69 ArrTemp = split(ArrLen(i),",")
70 if ubound(ArrTemp)<2 then
71 if cint(ArrTemp(1))<MinMargin then
72 MinMargin = cint(ArrTemp(1))
73 MinMarginStart = cint(ArrTemp(0))
74 MinMarginId = i
75 end if
76 end if
77next
78
79if MinMargin<>100000 then
80 response.write "包含所要求多个字符串的最短字符串为:" & mid(StrObj,MinMarginStart,MinMargin)
81else
82 response.write "包含所要求多个字符串的最短字符串为:制定的某字符串在整个字符串中不存在"
83end if
84
85
86
87%>
88
2function GetPos(start,word)
3 dim i,IntIndex,MaxIndex
4 dim flag
5 flag = 1
6 MaxIndex = 0
7 for i=0 to ubound(ArrWord)
8 if i<>cint(word) then
9 IntIndex = Instr(start+len(ArrWord(word)),StrObj,ArrWord(i))
10 if IntIndex>0 then
11 flag = flag + 1
12 'response.write flag & ":" & i & "<br>"
13 if MaxIndex<(IntIndex+len(ArrWord(i))) then
14 MaxIndex = IntIndex+len(ArrWord(i))
15 end if
16 end if
17 end if
18 next
19 if flag = ubound(ArrWord)+1 then
20 GetPos = "(" & start & "," & cstr(MaxIndex-start) & ")"
21 else
22 GetPos = "(1,2,3)"
23 end if
24
25end function
26
27function GetNearest()
28 dim i,StrResult,IntIndex,Seq,StrResult1
29 StrResult = ","
30 StrResult1 = ","
31 for i = 0 to ubound(ArrWord)
32 Seq = 1
33 IntIndex = Instr(Seq,StrObj,ArrWord(i))
34 do until IntIndex<1
35 StrResult = StrResult & IntIndex & ","
36 StrResult1 = StrResult1 & i & ","
37 Seq = IntIndex + Len(ArrWord(i))
38 IntIndex = Instr(Seq,StrObj,ArrWord(i))
39 loop
40 next
41 StrResult = left(StrResult,len(StrResult)-1)
42 StrResult = right(StrResult,len(StrResult)-1)
43 StrResult1 = left(StrResult1,len(StrResult1)-1)
44 StrResult1 = right(StrResult1,len(StrResult1)-1)
45 GetNearest = StrResult & "|" & StrResult1
46end function
47
48dim StrObj,ArrWord,ArrDotList,ArrWordList,ArrAll,i,ArrLen,StrLenList
49'StrObj="wer张三色单峰驼retert李四李四李四sdf张三色单峰驼rete34王五53赵六543543rt李四sdfwe"
50StrObj="aaa张三bbbb李四李四李四ccc张三dddddddd王五e赵六f李四ggg王五热土hhhhhhh赵六"
51ArrWord = Array("张三","李四","王五","赵六","刘七")
52ArrAll = split(GetNearest,"|")
53ArrDotList = split(ArrAll(0),",")
54ArrWordList = split(ArrAll(1),",")
55StrLenList = ""
56
57for i=0 to ubound(ArrDotList)
58 StrLenList = StrLenList & GetPos(ArrDotList(i),ArrWordList(i))
59next
60'response.write StrLenList & "<br>"
61StrLenList = left(StrLenList,len(StrLenList)-1)
62StrLenList = right(StrLenList,len(StrLenList)-1)
63
64ArrLen = split(StrLenList,")(")
65
66dim MinMarginId,MinMargin,ArrTemp,MinMarginStart
67MinMargin = 100000
68for i=0 to ubound(ArrLen)
69 ArrTemp = split(ArrLen(i),",")
70 if ubound(ArrTemp)<2 then
71 if cint(ArrTemp(1))<MinMargin then
72 MinMargin = cint(ArrTemp(1))
73 MinMarginStart = cint(ArrTemp(0))
74 MinMarginId = i
75 end if
76 end if
77next
78
79if MinMargin<>100000 then
80 response.write "包含所要求多个字符串的最短字符串为:" & mid(StrObj,MinMarginStart,MinMargin)
81else
82 response.write "包含所要求多个字符串的最短字符串为:制定的某字符串在整个字符串中不存在"
83end if
84
85
86
87%>
88