Merge pull request #5601 from varunu28/master

Fixed a bug in findWord method
This commit is contained in:
Eric Martin 2018-11-02 20:26:42 -05:00 committed by GitHub
commit ab821cb4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -11,11 +11,14 @@ public class WordIndexer {
String lowerCaseTextString = textString.toLowerCase();
String lowerCaseWord = word.toLowerCase();
while(index != -1){
index = lowerCaseTextString.indexOf(lowerCaseWord, index + 1);
if (index != -1) {
indexes.add(index);
while(index != -1) {
index = lowerCaseTextString.indexOf(lowerCaseWord, index);
if (index == -1) {
break;
}
indexes.add(index);
index++;
}
return indexes;
}