gpt4 book ai didi

asp 数组 重复删除函数(服务器之家增强版)

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 29 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章asp 数组 重复删除函数(服务器之家增强版)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

因为要写个东西用到,所以百度了一下,居然有朋友乱写,而且比较多,都没有认真测试过,只对字符可以,但是对数字就不可以,而且通用性很差,需要修改才可以真正使用。没办法就自己写了,经过测试完全没有问题,而且思路很方便,代码很短,如下:  。

复制代码代码如下:

<% 
function cxarraynull(cxstr1,cxstr2) 
if isarray(cxstr1) then 
cxarraynull = "对不起,参数1不能为数组" 
Exit Function 
end if 
if cxstr1 = "" or isempty(cxstr1) then 
cxarraynull = "nodate" 
Exit Function 
end if 
ss = split(cxstr1,cxstr2) 
cxs = cxstr2&ss(0)&cxstr2 
sss = cxs 
for m = 0 to ubound(ss) 
cc = cxstr2&ss(m)&cxstr2 
if instr(sss,cc)=0 then 
sss = sss&ss(m)&cxstr2 
end if 
next 
cxarraynull = right(sss,len(sss) - len(cxstr2)) 
cxarraynull = left(cxarraynull,len(cxarraynull) - len(cxstr2)) 
end Function 
%> 

使用方法和函数表示: 
1、cxarraynull(cxstr1,cxstr2)函数中的两个参数: 
cxstr1:要检测的数组变量,可以为空,或其它未知的错误数据,当为空或则为错误数据返回"nodate"。 
cxstr2:数组的分割符号,可以为空,或为chr(13)等,自动替换输出。 
2、测试代码: 
<% 
s="1,2,3,4,2,3,5,3" 
s=cxarraynull(s,",") 
response.write s 
%> 
输出:1,2,3,4,5 


我增强版本,解决了数组中最后一位的,逗号问题。 
复制代码代码如下:

<% 
function cxarraynull(cxstr1,cxstr2) 
if isarray(cxstr1) then 
cxarraynull = "对不起,参数1不能为数组" 
Exit Function 
end if 
if cxstr1 = "" or isempty(cxstr1) then 
cxarraynull = "nodate" 
Exit Function 
end if 
do while instr(cxstr1,",,")>0 
cxstr1=replace(cxstr1,",,",",") 
loop 
if right(cxstr1,1)="," then 
cxstr1=left(cxstr1,len(cxstr1)-1) 
end if 
ss = split(cxstr1,cxstr2) 
cxs = cxstr2&ss(0)&cxstr2 
sss = cxs 
for m = 0 to ubound(ss) 
cc = cxstr2&ss(m)&cxstr2 
if instr(sss,cc)=0 then 
sss = sss&ss(m)&cxstr2 
end if 
next 
cxarraynull = right(sss,len(sss) - len(cxstr2)) 
cxarraynull = left(cxarraynull,len(cxarraynull) - len(cxstr2)) 
end function 
%> 

测试代码: 
复制代码代码如下:

s="1,2,3,4,55,55,55,333,333,2,3,5,3,88,,,,,,,66,,66,,,,,,,,,,,,,,,,,,,,,,,," 
s=cxarraynull(s,",") 
response.write s 

最后此篇关于asp 数组 重复删除函数(服务器之家增强版)的文章就讲到这里了,如果你想了解更多关于asp 数组 重复删除函数(服务器之家增强版)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com