VBScriptフィルター機能
❮完全なVBScriptリファレンスFilter関数は、フィルター基準に基づいた文字列配列のサブセットを含むゼロベースの配列を返します。
注: valueパラメーターに一致するものが見つからない場合、Filter関数は空の配列を返します。
注:パラメーターinputstringsが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:
|
例
例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
フィルタ:「S」を含むアイテム、テキスト比較(compare = 1):
<%
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リファレンス