We help IT Professionals succeed at work.

cut string

leong9065
leong9065 asked
on
i have a string as below:


str1;str2;str3;str4;str5;.........

i need to cut each string seperate with ; and put in an array arr().
i use indexOF and substring.

how should i code my loop so that it can loop thru the str and cut out each one.
Comment
Watch Question

Commented:
You do not need to loop: there existss a special function for it, called split:

var arr = 'str1;str2;str3;str4;str5;.....'.split(';')

after that

arr.length is 6
and
arr[2] is 'str3'

Commented:
leong9065, I belive you have rescived your answer. Isn't it time to wrap this question up?
ahosangFinance Systems Developer

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to alexcohn
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
Per recommendation, force-accepted.

Netminder
EE Admin

Explore More ContentExplore courses, solutions, and other research materials related to this topic.