javascript - How to split the string in to different parts -
i want split string in different parts. have string generated dynamically contains 500 characters. want split in 5 parts. mean want take 100 characters in array[0], next 100 characters in array[1] ....
example:
var string = "kjfaorj......................................................."; array[0] = "kjfaorj..... 100 characters"; array[1] = " next 100 characters "; .......................... ..........................
if(str.length % 100 == 0) //if string contains 500 or 400...etc count = str.length / 100; else count = str.length / 100 +1; //if string contains 505 or 417...etc for(var i=0;i<count;i++) array[i] = s.substring(i*100,(i*100)+(100)); second approach dynamic string
Comments
Post a Comment