Vbscript-filter-function

提供:Dev Guides
移動先:案内検索

VBScriptフィルター関数

特定のフィルター条件に基づいた文字列配列のサブセットを含むゼロベースの配列を返すフィルター関数。

構文

Filter(inputstrings,value[,include[,compare]])
  • inputstrings 、必須パラメーター。 このパラメータは、検索する文字列の配列に対応しています。
  • 、必須パラメーター。 このパラメーターは、inputstringsパラメーターに対して検索するストリングに対応します。
  • include 、オプションのパラメーター。 これはブール値であり、包含または除外する部分文字列を返すかどうかを示します。
  • compare 、オプションのパラメーター。 このパラメーターは、使用するストリング比較方法を記述します。
  • 0 = vbBinaryCompare-バイナリ比較を実行します
  • 1 = vbTextCompare-テキスト比較を実行します

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         a = array("Red","Blue","Yellow")
         b = Filter(a,"B")
         c = Filter(a,"e")
         d = Filter(a,"Y")

         For each x in b
           Document.write("The Filter result 1: " & x & "<br/>")
         Next

         For each y in c
           Document.write("The Filter result 2: " & y & "<br/>")
         Next

         For each z in d
           Document.write("The Filter result 3: " & z & "<br/>")
         Next

      </script>
   </body>
</html>

上記のコードが.HTMLとして保存され、Internet Explorerで実行されると、次の結果が生成されます-

The Filter result 1: Blue
The Filter result 2: Red
The Filter result 2: Blue
The Filter result 2: Yellow
The Filter result 3: Yellow