1樓:匿名使用者
s="abcdiefacbdfabcedeffhklabihlefgh"
for each i in getstr(s,"ab","i","ef")
msgbox i
next
function getstr(s,a,b,c)dim arr()
dim i
dim re,ms
set re = new regexp
re.ignorecase = true
re.global = true
re.pattern = "(" & a & "(?:(?!" & a & ").)*?" & b & ".*?" & c & ")"
set ms = re.execute(s)redim arr(ms.count-1)for i = 0 to ms.
count - 1arr(i) = ms(i).submatches(0)next
getstr=arr
end function
2樓:匿名使用者
<%function domatches(s,a,b,c)
dim subjectstring = s;
dim myregexp, mymatches, mymatch
set myregexp = new regexp
'myregexp.pattern = "ab((?!ab).)*?i.*?ef"
myregexp.pattern = a+"((?!"+a+").)*?"+b+".*?"+c
set mymatches = myregexp.execute(subjectstring)
for each mymatch in mymatches
'這裡遍歷所有匹配,你可以列印出來看看,如
response.write(mymatch.value)
'matched text: mymatch.value
'match start: mymatch.firstindex
'match length: mymatch.length
'backreference n text: mymatch.submatches(n-1)
next
end function
%>
3樓:岔路程式緣
option explicit
function z(a as string, a1 as string, a2 as string, a3 as string) as string
dim m as integer, y as boolean
dim i as integer, j as integer, k as integer
dim l as integer, l1 as integer, l2 as integer, l3 as integer
l = len(a)
l1 = len(a1)
l2 = len(a2)
l3 = len(a3)
z = "原始字串:" + a + vbcrlf
m = 0
y = false
for i = 1 to l - l1 - l2 - l3 + 1
if mid(a, i, l1) = a1 then
for j = i + l1 to l - l2 - l3 + 1
y = false
if mid(a, j, l2) = a2 then
for k = j + l2 to l - l3 + 1
if mid(a, k, l3) = a3 then
m = m + 1
z = z + str(m) + space(5) + mid(a, i, k - i + l3) + vbcrlf
y = true
end if
if y then k = l - l3 + 1
next
end if
if y then j = l - l2 - l3 + 1
next
end if
next
z = z + "共找到" + str(m) + "個"
end function
private sub form_load()
form1.autoredraw = true
dim x as string, x1 as string, x2 as string, x3 as string
dim n as integer, n1 as integer, n2 as integer, n3 as integer
dox = inputbox("請輸入原字串(至少6個字)", , "abcdiefacbdfabcedeffhklabihlefgh")
n = len(x)
loop until n > 5
dox1 = inputbox("請輸入首字元(不多於" & n - 2 & "個字)", , "ab")
n1 = len(x1)
loop until n1 > 0 and n1 <= n - 2
dox2 = inputbox("請輸入中間字元(不多於" & n - n1 - 1 & "個字)", , "i")
n2 = len(x2)
loop until n2 > 0 and n2 <= n - n1 - 1
dox3 = inputbox("請輸入末尾字元(不多於" & n - n1 - n2 & "個字)", , "ef")
n3 = len(x3)
loop until n3 > 0 and n3 <= n - n1 - n2
print z(x, x1, x2, x3)
end sub
'輸入時一直按回車即可得到樓主所舉的例子。可以隨意改變輸入的字串。本程式已經執行過。
4樓:匿名使用者
誰說用instr函式就不穩定了?我這個偏用instr寫,也未見不好用。這個function完全是按照你的要求寫的,返回一個string——變數s。
你要測試此函式的可行性的話可以建一個command1,寫上本文最下面的幾行。
**如下。
******************************===
function s(byval a as string, byval b as string, byval c as string, byval d as string) as string
dim i as integer, j as integer, a1() as integer, a2() as integer
redim a1(0)
redim a2(0)
doi = i + 1
redim preserve a1(i)
a1(i) = instr(a1(i - 1) + 1, a, b)
loop until a1(i) = 0
i = 0
doi = i + 1
redim preserve a2(i)
a2(i) = instr(a2(i - 1) + 1, a, d)
loop until a2(i) = 0
i = 0
for i = 1 to ubound(a1) - 1
for j = 1 to ubound(a2) - 1
if a2(j) > a1(i) then
dim p as string
p = mid(a, a1(i), a2(j) - a1(i) + len(d))
if instr(1, p, c) > 0 and instr(1, p, d) > a2(j) - a1(i) then s = s & vbcrlf & p
end if
next
next
end function
private sub command1_click()
print s("abcdiefacbdfabcedeffhklabihlefgh", "ab", "i", "ef")
end sub
5樓:匿名使用者
(ab\s?^i+\s?ef)+
結構力學結構幾何構造分析題求高手解答啊
幾何不變體系無多餘約束。太久沒寫了,不曉得對不對。 百小度 簡單 我也簡單的說下 因為原體系和大地是三個支座相連,而三個支座可以將上面的部分固定住,所以相當於一個固定鉸支座和可動鉸支座和上面部分相連,可以直接將上面部分拿下來分析,這個能理解吧?拿下來分析就簡單多了,呵呵,因為可以看成兩個剛片1和2,...
求C 拷貝建構函式
q嘿仔 include using namespace std template class cmatrix nrow row ncol col 預設建構函式 void setcmatrix int row,int col,const t data 鍵盤輸入 void show 輸出 void in...
求高手一對,求高手推薦一對3000 5000元的音箱(音響) 最好是有源音箱,另外再給搭配下CD和功放。預算7000 1萬元。
愛hifi音響網 如果5000的預算的話,還是比較充足的來選擇音響的 漫步者做的不錯,不過總的來說主要是做低價音響的,5000的音響來說就不太推薦選擇漫步者了 惠威 丹拿這兩個品牌來說,惠威用時間長了會出現一些問題,也是根據使用者來說的,有些人不是很喜歡用這個品牌,丹拿來說,不會很低,具體型號具體分...