VBScript 분할 기능
❮ 완전한 VBScript 참조
Split 함수는 지정된 수의 하위 문자열을 포함하는 0부터 시작하는 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
delimiter 매개변수를 사용하여 텍스트 분할
<%
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
delimiter 매개변수와 count 매개변수를 사용하여 텍스트 분할
<%
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 참조