急!急!急!怎么过滤掉数字字符串中的重复数字?

lonely21 2008-11-05 04:04:28
怎么过滤掉数字字符串中的重复数字?

例:4,14,15,15,6,6,11,11

怎么变成:4,14,15,6,11
...全文
90 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2008-11-05
  • 打赏
  • 举报
回复
第一个方法:
function getStr(str)
strArr=split(str,",")
newstr=","
for i=0 to ubound(strArr)
newstr=replace(newstr, ","&strArr(i)&"," , ",")
newstr=newstr&strArr(i)&","
next
newstr=replace("#"&newstr,"#,","")
getStr=replace(newstr&"#",",#","")
end function

第二个方法:
Function FormateOrderBy(OrderByText)
Dim tmp,tmp2,i,j
tmp = Split(OrderByText,",")
For i=0 To Ubound(tmp)-1
For j=i+1 To Ubound(tmp)
If UCase(Trim(tmp(i)))=UCase(Trim(tmp(j))) Then
tmp(j)=""
End If
Next
Next
tmp2=""
For i=0 To Ubound(tmp)
If tmp(i) <>"" Then tmp2 = tmp2 & tmp(i) & ","
Next
FormateOrderBy = Left(tmp2,Len(tmp2)-1)
End Function
fssdcqzx 2008-11-05
  • 打赏
  • 举报
回复
为什么不写清楚一些你需要的代码是基于什么环境下的呢?这样回复更明确些啊
lonely21 2008-11-05
  • 打赏
  • 举报
回复
顶下
谁还有更好的答案
wtogether 2008-11-05
  • 打赏
  • 举报
回复

Dim dic, arr, ptr
arr = split("4,14,15,15,6,6,11,11", ",")
Set dic = Server.CreateObject("Scripting.Dictionary")
For Each ptr In arr
dic(ptr) = ptr
Next
arr = dic.items
Response.Write Join(arr, ",")

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧