VBScript 필터 기능

❮ 완전한 VBScript 참조

Filter 함수는 필터 기준에 따라 문자열 배열의 하위 집합을 포함하는 0부터 시작하는 배열을 반환합니다.

참고: value 매개변수와 일치하는 항목이 없으면 Filter 함수는 빈 배열을 반환합니다.

참고: 매개변수 입력 문자열이 Null이거나 1차원 배열이 아닌 경우 오류가 발생합니다.

통사론

Filter(inputstrings,value[,include[,compare]])
Parameter Description
inputstrings Required. A one-dimensional array of strings to be searched
value Required. The string to search for
include Optional. A Boolean value that indicates whether to return the substrings that include or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as a substring. Default is True.
compare Optional. Specifies the string comparison to use.

Can have one of the following values:

  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a textual comparison

실시예 1

필터: "S"가 포함된 항목

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
for each x in b
    response.write(x & "<br />")
next

%>

위 코드의 출력은 다음과 같습니다.

Sunday
Saturday

실시예 2

필터: "S"가 포함되지 않은 항목(include=False):

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
for each x in b
    response.write(x & "<br />")
next

%>

위 코드의 출력은 다음과 같습니다.

Monday
Tuesday
Wednesday
Thursday
Friday

실시예 3

필터: 텍스트 비교(비교=1)와 함께 "S"가 포함된 항목:

<%

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
for each x in b
    response.write(x & "<br />")
next

%>

위 코드의 출력은 다음과 같습니다.

Sunday
Tuesday
Wednesday
Thursday
Saturday

❮ 완전한 VBScript 참조