VBScript分割関数
❮完全なVBScriptリファレンス
Split関数は、指定された数のサブストリングを含むゼロベースの1次元配列を返します。
構文
Split(expression[,delimiter[,count[,compare]]])
Parameter | Description |
---|---|
expression | Required. A string expression that contains substrings and delimiters |
delimiter | Optional. A string character used to identify substring limits. Default is the space character |
count | Optional. The number of substrings to be returned. -1 indicates that all substrings are returned |
compare | Optional. Specifies the string comparison to use. Can have one of the following values:
|
例
例1
<%
a=Split("W3Schools is my favourite website")
for each x in a
response.write(x & "<br />")
next
%>
上記のコードの出力は次のようになります。
W3Schools
is
my
favourite
website
例2
区切り文字パラメーターを使用してテキストを分割する
<%
a=Split("Brown cow, White horse, Yellow chicken",",")
for each x in a
response.write(x & "<br />")
next
%>
上記のコードの出力は次のようになります。
Brown cow
White horse
Yellow chicken
例3
区切り文字パラメーターとカウントパラメーターを使用してテキストを分割する
<%
a=Split("W3Schools is my favourite website"," ",2)
for each x in a
response.write(x & "<br />")
next
%>
上記のコードの出力は次のようになります。
W3Schools
is my favourite website
例4
テキスト比較で区切り文字パラメーターを使用してテキストを分割します。
<%
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1)
for each x in a
response.write(x & "<br />")
next
%>
上記のコードの出力は次のようになります。
Sun
Mon
Tues
WEDNES
Thurs
Fri
Satur
例5
区切り文字パラメーターとバイナリ比較を使用してテキストを分割します。
<%
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,0)
for each x in a
response.write(x & "<br />")
next
%>
上記のコードの出力は次のようになります。
Sun
Mon
Tues
WEDNESDAYThurs
Fri
Satur
❮完全なVBScriptリファレンス