『壹』 ASP如何过滤数组内重复内容
dim a(4)
a(0)=1
a(1)=1
a(2)=2
a(3)=2
a(4)=3
for n=0 to ubound(a)-1
for s=1 to ubound(a)
if a(s)=a(n) then
a(n)=""
end if
next
next
a_new=filter(a,"")‘把a数组里面是空值的全部删掉,然后重新组合成一个a_new数组。
for n=0 to ubound(a_new)’打印出a_new数组。
response.write a_new(n)&"<br>"
next
说明:a_new是新生成的数组,去掉了a数组里面被清空的那些,重新生成了一个开头角标是0的a_new数组。
『贰』 去掉字符串中间的所有空格的asp代码怎么写
<%
dim mystr,myarray
mystr="Once upon a time,there were three bears."
myarray=SPLIT(mystr)'把字符串分割为数组,默认情况下以空格为分割符
myarray=FILTER(myarray,"t")
'函数FILTER()过滤掉所有不匹配字符串”t”的数组元素。
response.write JOIN(myarray)&"<br>"'把过滤后的字符串连接起来
%>
如果你想从一个句子中过滤掉包含字母t的每一个词,那么就在函数Filter()中加入参数false。如下所示:
<%
dim mystr,myarray
mystr="Once upon a time,there were three bears."
myarray=SPLIT(mystr)'把字符串分割为数组,默认情况下以空格为分割符
myarray=FILTER(myarray,"t",false)'函数FILTER()过滤掉匹配特定字符串"t"的所有数组元素
response.write JOIN(myarray)'把过滤后的字符串连接起来
%>
把T改为你想要的空格