日期:2014-05-16 浏览次数:20783 次
<%
str="1 2 3 6 5 8 9 7"
arr=split(str," ")
s=""
for i=0 to ubound(arr)
a=arr(i)
if i<ubound(arr) then
b=arr(i+1)
else
b=arr(i)
end if
if abs(b-a)=1 then
char="-"
else
char=","
end if
s=s&arr(i)&char
next
if right(s,1)="," then s=left(s,len(s)-1)
brr=split(s,",")
for i=0 to ubound(brr)
crr=split(brr(i),"-")
if ubound(crr)>0 then
for j=1 to ubound(crr)
s=replace(s,"-"&crr(j)&"-","-")
next
else
s=replace(s,crr(0),crr(0)&"-"&crr(0))
end if
next
response.write s
%>