关于字符串的处理
2007-12-21 13:45
239 查看
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
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
相关文章推荐
- 关于json时间字符串格式化处理
- 关于字符串处理的一系列类似算法
- [noip][c/c++]关于字符串中前导0和后导0的处理算法
- STL -- 关于一些字符串处理用到的函数和数据结构
- 关于SQL字符串处理的一些函数
- 如何在字符串中加入回车换行,tab字符(关于字符串处理)
- Java 关于字符串的处理
- cocos2dx中使用的tolua关于字符串处理的一个问题
- MFC几个关于字符串处理的全局函数
- 关于字符串处理
- 关于字符串处理的应用扩展
- 转: 关于Java中split方法对空字符串处理问题
- 关于字符串 “*****AB**C*D*****” 中前缀、后缀和中间 '*' 的处理
- 做了个关于字符串处理的题
- JS和Jquery中关于-字符串处理-的函数总结
- c# 关于WCF 接口参数 为 xml 格式的 字符串(string) 的 数据 处理
- 关于PHP的一些常用的字符串处理函数
- Lotus中关于字符串处理的函数汇总
- 关于零的字符串处理
- 对{php中关于处理字符串时效率的讨论}的改进