MCPcopy Create free account
hub / github.com/apache/commons-lang / removeEnd

Method removeEnd

src/main/java/org/apache/commons/lang3/Strings.java:1162–1170  ·  view source on GitHub ↗

Removal of a substring if it is at the end of a source string, otherwise returns the source string. A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string. Case-sensiti

(final String str, final CharSequence remove)

Source from the content-addressed store, hash-verified

1160 * @return the substring with the string removed if found, {@code null} if null String input
1161 */
1162 public String removeEnd(final String str, final CharSequence remove) {
1163 if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
1164 return str;
1165 }
1166 if (endsWith(str, remove)) {
1167 return str.substring(0, str.length() - remove.length());
1168 }
1169 return str;
1170 }
1171
1172 /**
1173 * Removal of a substring if it is at the beginning of a source string, otherwise returns the source string.

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.95
endsWithMethod · 0.95
substringMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected