Github user HiuKwok commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/340#discussion_r209878957 --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java --- @@ -5596,8 +5596,8 @@ private static String replace(final String text, String searchString, final Stri } String searchText = text; if (ignoreCase) { - searchText = text.toLowerCase(); - searchString = searchString.toLowerCase(); + searchText = text.toUpperCase(); + searchString = searchString.toUpperCase(); --- End diff -- @kinow It turn out the problem is large than that, because the incorrect length basically affecting the whole method, especially the part which involve parsing inside the while loop. https://github.com/apache/commons-lang/blob/590f90889bf61a5570bd98b78e73410a07d7410b/src/main/java/org/apache/commons/lang3/StringUtils.java#L5612-L5619 While string like following is entered, then Exception would be thrown on here instead. https://github.com/apache/commons-lang/blob/590f90889bf61a5570bd98b78e73410a07d7410b/src/main/java/org/apache/commons/lang3/StringUtils.java#L5613 ![image](https://user-images.githubusercontent.com/37996731/44082531-137cb1a0-9fe4-11e8-9219-8f373aebce67.png)
---