WMLScript elementAt() 함수

elementAt() 함수는 문자열을 요소로 나누고 지정된 인덱스 위치의 요소를 반환합니다.

문법

n = String.elementAt(string, index, separator)
소요 설명
n 함수로부터 반환된 문자열.
string 해석할 문자열.
index 반환되는 부분을 정의하는 정수.
separator 문자열을 구분하는 구분자.

주의:index가 음수이면 첫 번째 요소를 반환합니다. index의 값이 너무 크면 마지막 요소를 반환합니다.

예제

var a= String.elementAt("Visit CodeW3C.com today",0," ");
var b= String.elementAt("Visit CodeW3C.com today",1," ");
var c= String.elementAt("Visit CodeW3C.com today",2," ");
var d= String.elementAt("Apples+Bananas",0,"+");
var e= String.elementAt("Apples+Bananas",1,"+");
var f= String.elementAt("Apples+Bananas",5,"+");

결과

a = "Visit"
b = "W3School"
c = "today"
d = "Apples"
e = "Bananas"
f = "Bananas"