Vbscript-split-function

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

VBScript分割関数

分割関数は、区切り文字に基づいて分割された特定の数の値を含む配列を返します。

構文

Split(expression[,delimiter[,count[,compare]]])
  • expression 、必須パラメーター。 区切り文字付きの文字列を含むことができる文字列式。
  • delimiter 、オプションのパラメーター。 パラメータ。区切り文字に基づいて配列に変換するために使用されます。
  • count 、オプションのパラメーター。 返される部分文字列の数。-1として指定された場合、すべての部分文字列が返されます。
  • compare 、オプションのパラメーター。 このパラメーターは、使用する比較方法を指定します。
  • 0 = vbBinaryCompare-バイナリ比較を実行します
  • 1 = vbTextCompare-テキスト比較を実行します

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         ' Splitting based on delimiter comma '$'
         a = Split("Red $ Blue $ Yellow","$")
         b = ubound(a)

         For i = 0 to b
            document.write("The value of array in " & i & " is :"  & a(i)& "<br/>")
         Next

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

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

The value of array in 0 is :Red
The value of array in 1 is : Blue
The value of array in 2 is : Yellow