From 37e4ff9bdd3c16ac4f0f4a2467aaf6b84d0f44e9 Mon Sep 17 00:00:00 2001 From: Joel David Gallant Date: Mon, 1 Jul 2013 14:27:31 -0600 Subject: [PATCH] Fixed small bug in index that didn't return -1 when needed --- src/edu/first/util/Strings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/edu/first/util/Strings.java b/src/edu/first/util/Strings.java index 7b37ad7..125f613 100644 --- a/src/edu/first/util/Strings.java +++ b/src/edu/first/util/Strings.java @@ -38,11 +38,11 @@ public static boolean isEmpty(String string) { public static int indexThatIsnt(String string, String s, String i) { int index; int spare = 0; - while ((index = string.indexOf(s)) > 0 && index == string.indexOf(i)) { + while ((index = string.indexOf(s)) >= 0 && index == string.indexOf(i)) { string = string.substring(index + i.length()); spare += index + i.length(); } - return index + spare; + return index < 0 ? -1 : index + spare; } /**