asp 字符串格式化问题 20
源字符串TL8BA1=on&TL8BA2=on&TL8BB1=on&TL8BB2=on&MHXYA2=on&MHXYB2=on输出字符串TL8B/A:1.2.B:1.2,...
源字符串 TL8BA1=on&TL8BA2=on&TL8BB1=on&TL8BB2=on&MHXYA2=on&MHXYB2=on
输出字符串 TL8B/A:1.2.B:1.2,MHXY/A:2.B:2
请大家帮帮忙 展开
输出字符串 TL8B/A:1.2.B:1.2,MHXY/A:2.B:2
请大家帮帮忙 展开
2个回答
展开全部
看了十几分钟才看清楚需求
要求很奇怪,虽然我做出来了,但是还是建议你是不是能从源头对这些字符串进行优化处理,以下是你想要的结果,需要用到ASP不常用的数组过滤函数filter,大体的写了下注释:
dim s,sResult
s="TL8BA1=on&TL8BA2=on&TL8BB1=on&TL8BB2=on&MHXYA2=on&MHXYB2=on"
'sResult="TL8B/A:1.2.B:1.2,MHXY/A:2.B:2"
dim a,i
a=split(s,"&")
dim aFilter,bControl,sT,aT
aFilter=a
while ubound(aFilter)>-1
sT=left(aFilter(0),4)
a=Filter(aFilter,sT,false)'取得非匹配结果
aFilter=Filter(aFilter,sT)
if ubound(aFilter)>-1 then
sResult=sResult&sT&"/"'拼接前四位
'处理匹配结果
while ubound(aFilter)>-1
sT=left(aFilter(0),5)
aT=Filter(aFilter,sT)'取得同组
if ubound(aT)>-1 then
sResult=sResult&right(sT,1)&":"'拼接第五位
for i=0 to ubound(aT)
'response.write mid(aT(i),6,1)&"<br />"
sResult=sResult&mid(aT(i),6,1)&"."
next
end if
aFilter=Filter(aFilter,sT,false)
'response.write join(aFilter,"&")&"<br />"
wend
sResult=left(sResult,len(sResult)-1)&","
end if
aFilter=a
'response.write join(aFilter,"&")&"<br />"
wend
if sResult<>"" then sResult=left(sResult,len(sResult)-1)
response.write sResult
要求很奇怪,虽然我做出来了,但是还是建议你是不是能从源头对这些字符串进行优化处理,以下是你想要的结果,需要用到ASP不常用的数组过滤函数filter,大体的写了下注释:
dim s,sResult
s="TL8BA1=on&TL8BA2=on&TL8BB1=on&TL8BB2=on&MHXYA2=on&MHXYB2=on"
'sResult="TL8B/A:1.2.B:1.2,MHXY/A:2.B:2"
dim a,i
a=split(s,"&")
dim aFilter,bControl,sT,aT
aFilter=a
while ubound(aFilter)>-1
sT=left(aFilter(0),4)
a=Filter(aFilter,sT,false)'取得非匹配结果
aFilter=Filter(aFilter,sT)
if ubound(aFilter)>-1 then
sResult=sResult&sT&"/"'拼接前四位
'处理匹配结果
while ubound(aFilter)>-1
sT=left(aFilter(0),5)
aT=Filter(aFilter,sT)'取得同组
if ubound(aT)>-1 then
sResult=sResult&right(sT,1)&":"'拼接第五位
for i=0 to ubound(aT)
'response.write mid(aT(i),6,1)&"<br />"
sResult=sResult&mid(aT(i),6,1)&"."
next
end if
aFilter=Filter(aFilter,sT,false)
'response.write join(aFilter,"&")&"<br />"
wend
sResult=left(sResult,len(sResult)-1)&","
end if
aFilter=a
'response.write join(aFilter,"&")&"<br />"
wend
if sResult<>"" then sResult=left(sResult,len(sResult)-1)
response.write sResult
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询