作者列表字符串(str1):
张三<sup><a href="#dw1">a</a></sup>
李四<sup><a href="#dw2">b</a></sup>
王二<sup><a href="#dw2">a</a>,<a href="#dw3">c</a></sup>作者单位列表字符串(str2):
<span id=dw1>a.</span> 单位一<br>
<span id=dw2>b.</span> 单位二<br>
<span id=dw3>c.</span> 单位三<br>想得到结果字符串(str3):
张三:单位一;
李四:单位二;
王二:单位一,单位三;
如果通过str1,str2,得到str3的函数如何写?先谢谢了!!
求解以下函数:
function fun(str1,str2) as string
'传入参数str1:作者列表;
'传入参数str2:作者单位列表;
'返回字符串str3;
end function
'传入参数str1:作者列表;
'传入参数str2:作者单位列表;
'返回字符串str3;
dim tmp,temp1,temp2
dim i as long
dim str3 as string
str2=replace(str2,"br>","")
str2=replace(str2,">","<")
temp1=split(str1,vbcrlf)
temp2=split(str2,vbcrlf)
for i=0 to ubound(temp1)
if trim(temp1(i))<>"" then
tmp=temp1(i) & temp2(1)
tmp=split(tmp,"<")
str3=str3 & tmp(0) & tmp(ubound(tmp)-1) & vbcrlf
end if
next
fun=str3
end function
'传入参数str1:作者列表;
'传入参数str2:作者单位列表;
'返回字符串str3;
dim tmp,temp1,temp2
dim i as long
dim str3 as string
str2=replace(str2,"br>","")
str2=replace(str2,">"," <")
temp1=split(str1,vbcrlf)
temp2=split(str2,vbcrlf)
for i=0 to ubound(temp1)
if trim(temp1(i)) <>"" then
tmp=temp1(i) & temp2(i)
tmp=split(tmp," <")
str3=str3 & tmp(0) & tmp(ubound(tmp)-1) & vbcrlf
end if
next
fun=str3
end function