假设现在有如下字符串:
str="1/1,A,0.1*1/1,B,0.2*1/2,A,0.2*1/3,B,0.2*1/4,A,0.1*1/4,B,0.1"
现在按照1/1,1/2,1/3,1/4进行分别输出如下格式(当当日没有数据时则用”-“代替):
1/1 A 0.1
1/1 B 0.2
1/2 A 0.2
1/2 B -
1/3 A -
1/3 B 0.2
1/4 A -
1/4 B 0.1
请高手指点一下
str="1/1,A,0.1*1/1,B,0.2*1/2,A,0*1/3,B,0.2*1/4,A,0.1*1/4,B"
arr=split(str,"*")
l=ubound(arr)
for i=0 to l
itemarr=split(arr(i),",")
ll=ubound(itemarr)
response.Write itemarr(0)&" "&itemarr(1)&" "
if ll>1 then
response.write itemarr(2)
else
response.Write "-"
end if
response.Write "<BR>"
next
string[] data = new string[]{"1/1 A -",......"1/1 B -"} ,然后 string[] result =str.split('*')得到实际数据数组,两个数组元素对比
for(int i = 0;i<data.length,i++)
{
if(data[i].split(' ')[0] == result[i].split(' ')[0])
{
data[i].replace('-',result[i].split(' ')[2])
}
else
{
continue;
}
}
data就是你要的数组