The function endsWith in standard library returns false also when the searched substring is contained twice in string. Example : fn:endsWith( 'abcdb' ,'b' ) returns false. Original source code : public static boolean endsWith(String input, String substring) { if (input == null) input = ""; if (substring == null) substring = ""; int index = input.indexOf(substring); if (index == -1) return false; if (index == 0 && substring.length() == 0) return true; return (index == input.length() - substring.length()); } should be : public static boolean endsWith(String input, String substring) { if (input == null) input = ""; if (substring == null) substring = ""; int index = input.lastIndexOf(substring); if (index == -1) return false; if (index == 0 && substring.length() == 0) return true; return (index == input.length() - substring.length()); }
Thanks for the fix Rastislav Rehak. The fix was committed by Pierre Delisle. Marking this bug fixed. -Dhiru
*** Bug 48848 has been marked as a duplicate of this bug. ***