[SOLVED] Help fix my infinite loop
Posted: Fri Apr 01, 2005 5:32 am
Hi,
Me again.... I'm having one my rubbish days where I can't think and nothing's going right
I must have this all wrong. Never mind what I need it for (it's a small part of a function). It just crashes the browser. It should skip along the original string counting up each time it hits a double quote.
Thanks
Me again.... I'm having one my rubbish days where I can't think and nothing's going right
Code: Select all
xString = 'I have some double "e;quotes"e; in me like "e;this"e; :-)';
xLength = xString.length;
xIndex = 0; //Position in string
xCount = 0; //Odd or even (opening or closing)
while (xIndex < xLength) {
if (xString.indexOf('"e;')) {
xIndex = xString.indexOf('"e;')+1; //Position of first quote in string (+1)
xString = xString.substr(xIndex); //Cut string
xCount++;
} else {
xIndex = xLength;
}
}
alert(xCount);Thanks