I am trying to parse a text line by line and then parse a line on tokens with 't' as the delimiter.
Please consider the following code:
str = "atbtcn1t2t3nxtytz"
console.log( str + "n");
i = 0;
j = str.indexOf( "n", i );
sstr = str.substr( i, j );
tokens = sstr.split( 't' );
console.log( tokens + "n" );
i = j + 1;
j = str.indexOf( "n", i ); // (*)
sstr = str.substr( i, j );
console.log( sstr + "n");
tokens = sstr.split( "t" );
console.log( tokens + "n" ); // (**)
You may run it on https://repl.it/C9r0
Can you explain why when I call console.log( tokens + "n" ); // (**) second time I got
1,2,3
x,y,z
instead of
1,2,3
Did I make a mistake?
