Thursday, February 24, 2005

Recursive Search String

private static int levelSearch(String cmts, String searchStr, int _start, int _total) throws Exception {
if ((cmts != null) && (searchStr != null)) {

String a = cmts.trim().toLowerCase();
String b = searchStr.toLowerCase();
System.out.println(a + " " + _total);
int ln = a.indexOf(b,_start);

int max = ln + searchStr.length() + 1;
if (max > cmts.length())
return _total + 1;

if (ln >= 0) {
return levelSearch(cmts.substring(ln + searchStr.length() + 1),
searchStr, 0, _total + 1);
} else {
return _total;
} /// end of the if //

} /// end of the if //
return 1;
} /// end of the method //

0 Comments:

Post a Comment

<< Home