I have a text content as follows:
var text = "asd^dfdf^dsfgdsfg^zdfsd^sdfsdf^dfsdf^dsfsdf^dfsdf^dfsf^sdfsdf^..."
I want to split the text up-to multiple of 5th occurrence of ^
and pass to a function with the ^
symbol.
If there are 31 ^
in the element then: 5th, 10th, 15th, 20th, 25th, 30th and then remaining should be passed to the function (i.e. 31st with ^
).
I prefer a for
loop like:
var spl = text.split(); //up-to 5th multiple
for(i=0; i<spl.length; i++){
passfun(upto 5th^ with cap symbol)
}
Example:
var text = "asd^dfdf^dsfgdsfg^zdfsd^sdfsdf^dfsdf^dsfsdf^dfsdf^dfsf^sdfsdf^sssad^gsds..."
passfun("asd^dfdf^dsfgdsfg^zdfsd^sdfsdf^"); //1st time
passfun("dfsdf^dsfsdf^dfsdf^dfsf^sdfsdf^");//2nd time
passfun("sssad^gsds");//last