Because it is necessary to write something for use, Baidu has a bit of it, and some friends have made a lot of things, and they have not been carefully tested. Only the characters are acceptable, but not the numbers, in addition, the versatility is very poor and can be used only after modification. There is no way to write it on your own. After testing, there is no problem, and the idea is very convenient,CodeVery short, as follows:
Copy code The Code is as follows: <%
Function cxarraynull (cxstr1, cxstr2)
If isarray (cxstr1) then
Cxarraynull = "sorry, parameter 1 cannot be an array"
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
%>
Usage and function representation:
1. Two Parameters in the cxarraynull (cxstr1, cxstr2) function:
Cxstr1: array variable to be checked. It can be null or other unknown error data. If it is null or it is error data, "nodate" is returned ".
Cxstr2: the delimiter of the array. It can be null or CHR (13). The output is automatically replaced.
2. Test code:
<%
S = "1, 2, 3, 3, 3, 5, 3"
S = cxarraynull (S ,",")
Response. Write s
%>
Output: 1, 2, 3, 4, 5
script enhanced version solves the comma (,) Problem of the last digit in the array.
copy Code the code is as follows: <%
function cxarraynull (cxstr1, cxstr2)
If isarray (cxstr1) then
cxarraynull = "sorry, parameter 1 cannot be an array"
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
%>
test code: copy Code the code is as follows: S =" 55,333,333, 55, 88, 66, 66 ,,,,,,,,,,,,,,,,,,,,,,,, "
S = cxarraynull (S,", ")
response. write S