찾다
웹 프론트엔드JS 튜토리얼ASP 필터 배열 중복 데이터 기능(향상 버전)_javascript 기술

기능 코드:

코드 복사 코드는 다음과 같습니다:

'필터 배열 중복 함수 이름: array_no(cxstr1,cxstr2,cxstr3)
'cxstr1: 모든 문자열, 자동으로 인식
'cxstr2: cxstr1의 분할 기호.
'cxstr3: 결과의 특정 위치에서 문자열을 추출합니다. 0과 같으면 모두 반환하고, 배열 첨자보다 크면 마지막을 반환합니다.
'에 사용됩니다. 2차원 배열
'****** ************************************ *************
function array_no(cxstr1,cxstr2,cxstr3)
if len(cxstr3) > 0이면
IsNumeric(cxstr3)이 아니면
array_no = "죄송합니다. 매개변수 3의 유형은 숫자여야 합니다."
Exit Function
end if
else
array_no = "죄송합니다. 매개변수 3의 유형은 숫자여야 합니다."
종료 함수
end if
if isarray(cxstr1) then
array_no = "죄송합니다. 매개변수 1은 배열이 될 수 없습니다."
함수 종료
end if
if cxstr1 = "" 또는 isempty (cxstr1) then
array_no = "데이터 없음"
함수 종료
end if
ss = Split(cxstr1,cxstr2)
cxs=cxstr2&ss(0)&cxstr2
sss=cxs
m = 0에서 ubound(ss)로
cc ​​​​= cxstr2&ss(m)&cxstr2
if instr(sss,cc)=0이면
sss = sss&ss(m)&cxstr2
end if
next
array_no = right(sss,len(sss)-len( cxstr2))
array_no = left(array_no,len(array_no)-len(cxstr2))
if cxstr3 < ;> 0이면
cx_sp = Split(array_no,cxstr2)
if cxstr3 > ; ubound(cx_sp)이면
array_no = cx_sp(ubound(cx_sp))
else
array_no = cx_sp (cxstr3)
end if
end if
end function%>


다음은 테스트 코드입니다.
코드 복사 코드는 다음과 같습니다.

s2 = "1,2,3,11,22,33,12, 13,14,11,33,333,14"
s3 = ""
s4 = "sdf,abc,12,2,2,abc"
s5 = Split(s4)
response.write "문자열이 문자인 경우:"&array_no(s1,",",0)&"< ;br>"
response.write "문자열이 숫자인 경우:"&array_no(s2,",",0)& "
"
response.write "문자열이 비어 있는 경우: " &array_no(s3,",",0)&"
"
response.write "문자열이 혼합된 경우: "&array_no(s4,",",0)&"
" >response.write "문자열이 배열인 경우: "&array_no(s5,",",0)&"
"
response.write "문자열이 알 수 없는 변수인 경우:"&array_no(s33, ",",0)&"
"
response.write "특정 비트를 추출할 때 아래 첨자를 초과하지 않는 경우: "&array_no(s1,",",2)&"
"
response.write "특정 비트를 추출할 때 첨자를 초과하는 경우: "&array_no(s1,",",200)&"< ;br>"%>

테스트 결과:

코드 복사 코드는 다음과 같습니다.
문자열이 문자인 경우 : abc,aa,bb,cdef,bc,abcdef,hhgg,gggg,cde,edc
문자열이 숫자인 경우: 1,2,3,11,22 ,33,12,13,14,333
문자열이 비어있는 경우: 데이터가 없습니다
문자열이 혼합되어 있는 경우: sdf,abc,12,2
문자열이 배열인 경우: 죄송합니다. 매개변수 1은 불가능합니다 배열
문자열이 있는 경우 알 수 없는 변수: 데이터가 없습니다
특정 비트 추출 시 첨자를 초과하지 않은 경우: bb
특정 비트 추출 시 첨자를 초과한 경우: edc



Script House의 향상된 버전: 일반적인 배열 오류 해결
코드 복사 코드는 다음과 같습니다.

'**************************************** ***** ******************
'필터 배열 중복 함수 이름: array_no(cxstr1,cxstr2,cxstr3)
'cxstr1: 임의의 문자열, 자동 인식
'cxstr2: cxstr1의 분할 기호.
'cxstr3: 결과의 특정 위치에서 문자열을 추출합니다. 0과 같으면 모두 반환하고, 배열 첨자보다 크면 마지막을 반환합니다.
'에 사용됩니다. 2차원 배열
'****** ************************************ *************
function array_no(cxstr1,cxstr2,cxstr3)
if len(cxstr3) > 0이면
IsNumeric(cxstr3)이 아니면
array_no = "죄송합니다. 매개변수 3의 유형은 숫자여야 합니다."
Exit Function
end if
else
array_no = "죄송합니다. 매개변수 3의 유형은 숫자여야 합니다."
종료 함수
end if
if isarray(cxstr1) then
array_no = "죄송합니다. 매개변수 1은 배열이 될 수 없습니다."
함수 종료
end if
if cxstr1 = "" 또는 isempty (cxstr1) then
array_no = "데이터 없음"
함수 종료
end if
do while instr(cxstr1,",,")>0
cxstr1=replace(cxstr1," ,,",",")
루프
if right(cxstr1, 1)="," then
cxstr1=left(cxstr1,len(cxstr1)-1)
end if
ss = 분할(cxstr1,cxstr2)
cxs=cxstr2&ss(0)&cxstr2
sss=cxs
for m = 0에서 ubound(ss)
cc ​​​​= cxstr2&ss(m)&cxstr2
if instr(sss,cc)=0이면
sss = sss&ss(m)&cxstr2
end if
next
array_no = right(sss,len(sss)-len(cxstr2)) array_no = cx_sp(ubound(cx_sp))
else
array_no = cx_sp(cxstr3)
end if
end if
end function

s1 = "abc,aa,bb,cdef,bc,abcdef,hhgg,gggg,cde,edc, 333,,,,,333,7,,,,"
s2 = "1,2,3,11, 22,33,12,13,14,11,33,333,14,333,,,,,333, 7,,,,"
s3 = ""
s4 = "sdf,abc,12,2,2 ,abc,333,,,,,333,7,,,,"
s5 = Split(s4)
response.write "문자열이 문자인 경우:"&array_no(s1,",",0 )&"
"
response.write "문자열이 숫자인 경우:"&array_no (s2,",",0)&"

response.write "문자열이 숫자인 경우 비어 있음:"&array_no(s3,",",0)&"
"
response.write "문자열이 혼합 문자열인 경우:"&array_no(s4,",",0)&"< ;br>"
response.write "문자열이 배열인 경우:"&array_no(s5,",", 0)&"
"
response.write "문자열이 알 수 없는 변수인 경우 :"&array_no(s33,",",0)&"
"
response.write "특정 숫자 추출 하나의 숫자를 추출할 때 아래 첨자를 초과하지 않습니다: "&array_no(s1,",", 2)&"
"
response.write "특정 숫자가 추출되면 아래 첨자가 초과됩니다: "&array_no(s1 ,",",200)&"
% >


주로 판단 추가



코드 복사
코드는 다음과 같습니다. while instr(cxstr1,",,")>0 cxstr1=replace(cxstr1,",,", ",") 루프
if right(cxstr1,1 )="," then
cxstr1=left(cxstr1,len(cxstr1)-1)
end if

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
php 怎么求2个数组相同的元素php 怎么求2个数组相同的元素Dec 23, 2022 am 10:04 AM

php求2个数组相同元素的方法:1、创建一个php示例文件;2、定义两个有相同元素的数组;3、使用“array_intersect($array1,$array2)”或“array_intersect_assoc()”方法获取两个数组相同元素即可。

c语言数组如何初始化c语言数组如何初始化Jan 04, 2023 pm 03:36 PM

C语言数组初始化的三种方式:1、在定义时直接赋值,语法“数据类型 arrayName[index] = {值};”;2、利用for循环初始化,语法“for (int i=0;i<3;i++) {arr[i] = i;}”;3、使用memset()函数初始化,语法“memset(arr, 0, sizeof(int) * 3)”。

c++数组怎么初始化c++数组怎么初始化Oct 15, 2021 pm 02:09 PM

c++初始化数组的方法:1、先定义数组再给数组赋值,语法“数据类型 数组名[length];数组名[下标]=值;”;2、定义数组时初始化数组,语法“数据类型 数组名[length]=[值列表]”。

javascript怎么给数组中增加元素javascript怎么给数组中增加元素Nov 04, 2021 pm 12:07 PM

增加元素的方法:1、使用unshift()函数在数组开头插入元素;2、使用push()函数在数组末尾插入元素;3、使用concat()函数在数组末尾插入元素;4、使用splice()函数根据数组下标,在任意位置添加元素。

php怎么判断数组里面是否存在某元素php怎么判断数组里面是否存在某元素Dec 26, 2022 am 09:33 AM

php判断数组里面是否存在某元素的方法:1、通过“in_array”函数在数组中搜索给定的值;2、使用“array_key_exists()”函数判断某个数组中是否存在指定的key;3、使用“array_search()”在数组中查找一个键值。

php 怎么去除第一个数组元素php 怎么去除第一个数组元素Dec 23, 2022 am 10:38 AM

php去除第一个数组元素的方法:1、新建一个php文件,并创建一个数组;2、使用“array_shift”方法删除数组首个元素;3、通过“print_”r输出数组即可。

asp内置对象有哪些asp内置对象有哪些Nov 09, 2023 am 11:32 AM

asp内置对象有Request、Response、Session、Application、Server、Session.Contents、Application.Contents、Server.CreateObject、Server.MapPath、Server.Execute、Server.Transfer等。详细介绍:1、Request:表示HTTP请求对象等等。

详解Go语言中删除数组元素的方法详解Go语言中删除数组元素的方法Mar 22, 2023 pm 03:21 PM

在Go语言中,数组是一种重要的数据类型。它与其他语言的数组一样,是一组相同类型的数据组成,可以通过一个索引来访问数组中的元素。在某些情况下,我们需要从一个数组中删除元素,本文将会介绍在Go语言中如何实现数组删除。

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

PhpStorm 맥 버전

PhpStorm 맥 버전

최신(2018.2.1) 전문 PHP 통합 개발 도구

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.