关于字符串的处理

str1="中文1,中文2,中文3,中文4,中文5,中文6"
str2="num1,mun2,num3,num4,num5,num6"

上面两个字符串是对应的:
num1对应着中文1
num2对应着中文2
num3对应着中文3
........................

str3="num3,num5"


如何根据上面的三个字符串得到
str4="中文3,中文5"
str5="中文1,中文2,中文4,中文6," 

--------------------------------------------------------------------------------------------------

dim str1,str2,str3,str4,str5
str1
= "中文1,中文2,中文3,中文4,中文5,中文6"
str2
= "num1,num2,num3,num4,num5,num6"

'type参数是搜索str3在str1或者str2,1是在str1,2是在str2
function getSplit(str3,ReType)
  str4
="":str5=""
 
dim ss1,ss2,ss3,i,index
  ss1
=split(str1,",")
  ss2
=split(str2,",")
  ss3
=split(str3,",")
 
for i=0 to ubound(ss3)
   
if ReType=1 then
      index
=getIndex(ss1,ss3(i))
     
if index<>-1 then
        str5
=str5&","&ss2(index)
        ss2(index)
=""'消除这个的值
      end if
   
else
      index
=getIndex(ss2,ss3(i))
     
if index<>-1 then
        str5
=str5&","&ss1(index)
        ss1(index)
=""
     
end if
   
end if
 
next
   
 
if ReType=1 then
   
for each s in ss2
     
if s<>"" then str4=str4&","&s
   
next
 
else
   
for each s in ss1
     
if s<>"" then str4=str4&","&s
   
next
 
end if
  str4
=right(str4,len(str4)-1)
  str5
=right(str5,len(str5)-1)
end function

'获取ss3中的值在ss1或者ss2中的下标位置
function getIndex(ss,Value)
dim k
for k=0 to ubound(ss)
  
if ss(k)=Value then
     getIndex
=k
    
exit function
  
end if
next
getIndex
=-1
end function

getSplit
"num3,num5",2
response.Write
"str4="""&str4&"""<br/>"
response.Write
"str5="""&str5&"""<br/>"

response.Write
"<br/>"

getSplit
"中文3,中文5",1
response.Write
"str4="""&str4&"""<br/>"
response.Write
"str5="""&str5&"""<br/>"

----------------------------------------------------------------------------

http://topic.csdn.net/u/20071220/22/33b8dddb-f6da-4417-a95c-e05060e3c527.html?seed=977250335

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值