Skip to content

StringUtils.endsWithIgnoreCase

Signature: StringUtils.endsWithIgnoreCase(inputString, suffix)

Returns: Boolean result - true if the inputString ends with the suffix, case insensitive, or both null

Case insensitive check if a inputString ends with a specified suffix. nulls are handled without exceptions. The comparison is case insensitive.

Parameters

Type Name Description Default
String inputString the String to check, may be null
String suffix the suffix to find, may be null

Example

// Example: case-insensitive suffix check (null-safe).

StringUtils.endsWithIgnoreCase(
    "Do I contain what you are looking for?", "?"
);  // true

StringUtils.endsWithIgnoreCase(
    "Do I contain what you are looking for?", "FOR?"
);  // true

StringUtils.endsWithIgnoreCase(
    "Do I contain what you are looking for?", "for"
);  // false

StringUtils.endsWithIgnoreCase(
    null, null
);  // true

StringUtils.endsWithIgnoreCase(
    null, "?"
);  // false