I have a
string and parsing through it, trying to discover the next instance of a single-quote ', a parenthesis ), a new-line \n, or a space.
Basically, I want to find out which one has the lowest number in an indexOf, but if the indexOf == -1, I want to exclude them from the check.
int nLineTest = restOfQry.indexOf("\n");
int quoteTest = restOfQry.indexOf('\'');
int parenTest = restOfQry.indexOf(')');
int spaceTest = restOfQry.indexOf(' ');
int lowestNum = 0;
// Find the location of the end of the parameter in qryText
if (Math.min(Math.min(quoteTest,nLineTest),Math.min(parenTest,spaceTest)) > -1) {
lowestNum += Math.min(Math.min(quoteTest,nLineTest),,Math.min(parenTest,spaceTest));
} else if (quoteTest > -1) {
lowestNum += quoteTest;
} else if (parenTest > -1) {
lowestNum += parenTest;
} else if (spaceTest > -1) {
lowestNum += spaceTest;
} else if (nLineTest > -1) {
lowestNum += nLineTest;
} else {
lowestNum = myQuery.length();
}
Also, if all of the above are equal to -1, then I need to know that too. What's the simplest way to do this, maybe using Math.min or something.
Thanks,
Matt