If string endswith the suffix, remove it. Else leave it alone.
979876
def _clean_suffix(string, suffix):
    
    suffix_len = len(suffix)

    if len(string) < suffix_len:
        # the string param was shorter than the suffix
        raise ValueError("A suffix can not be bigger than string argument.")
    if string.endswith(suffix):
        # return from the beginning up to
        # but not including the first letter
        # in the suffix
        return string[0:-suffix_len]
    else:
        # leave unharmed
        return string
949535
function endsWithAny(string, vector) {
  return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
}
81015
function hasSuffix(text, suffix) {
  let exp = new RegExp(`${suffix.pattern}$`);
  let result = exp.test(text);

  if (suffix.antipattern) {
    let exp = new RegExp(`${suffix.antipattern}$`);
    result = result && !exp.test(text);
  }

  return result;
}
882935
def endswith_strip(s, endswith='.txt', ignorecase=True):
    
    if ignorecase:
        if s.lower().endswith(endswith.lower()):
            return s[:-len(endswith)]
    else:
        if s.endswith(endswith):
            return s[:-len(endswith)]
    return s
1323102
public static boolean endsWithIgnoreCase(@Nullable final String str,
      @Nullable final String suffix) {
    return str != null && suffix != null && str.length() >= suffix.length()
        && str.regionMatches(true, str.length() - suffix.length(), suffix, 0, suffix.length());
  }
1218599
private String suffix(final String line) {
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if (c == ' ' || c == '\t') return line.substring(i + 1);
        }
        return "";
    }
1347752
public static String removeLast(String original, String string) {
		int lastIndexOf = original.lastIndexOf(string);
		if (lastIndexOf == -1) {
			return original;
		}
		return original.substring(0, lastIndexOf);
	}
996431
def remove_major_minor_suffix(scripts):
    
    minor_major_regex = re.compile("-\d.?\d?$")
    return [x for x in scripts if not minor_major_regex.search(x)]
1222046
public static String removeEnd(final String s, final char c) {
		if (endWith(s, c)) {
			return s.substring(0, s.length() - 1);
		}
		return s;
	}
253350
def suffix(self):
        """"""
        name = self.name
        i = name.rfind('.')
        if 0 < i < len(name) - 1:
            return name[i:]
        else:
            return ''
849062
def remove_suffix(text, suffix):
	
	rest, suffix, null = text.partition(suffix)
	return rest
131184
def any_ends_with(self, string_list, pattern):
        """"""
        try:
            s_base = basestring
        except:
            s_base = str
        is_string = isinstance(pattern, s_base)

        if not is_string:
            return False
        for s in string_list:
            if pattern.endswith(s):
                return True

        return False
780613
function _remove_url_suffix()
	{
		if  ($this->config->item('url_suffix') != "")
		{
			$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
		}
	}
393498
private static String stripFileExtensionIfAny(final String name) {
        final int suffix = name.lastIndexOf(".html");
        return suffix == -1 ? name : name.substring(0, suffix);
    }
1182013
public static function removeSuffix($string, $suffix)
    {
        if (self::endsWith($string, $suffix)) {
            return mb_substr($string, 0, -mb_strlen($suffix));
        }
        return $string;
    }
374784
def delete_suffixes(self, word):
        
        length = len(word)
        suffixes = ['al', 'ance', 'ence', 'er', 'ic', 'able', 'ible',
                    'ant', 'ement', 'ment', 'ent', 'ism', 'ate',
                    'iti', 'ous', 'ive', 'ize']

        for suffix in suffixes:
            if word.endswith(suffix) and self.r2 <= (length - len(suffix)):
                word = word[:-len(suffix)]
                return word

        if word.endswith('ion') and self.r2 <= (length - 3):
            if word[length - 4] in 'st':
                word = word[:-3]

        return word
1308921
protected boolean endsWithIgnoreCase(String name, String suffix) {
		if (name == null || suffix == null) {
			/*
			 * No name or no suffix. Return false.
			 */
			return false;
		}
		int i = name.length() - suffix.length();
		if (i < 0) {
			/*
			 * Suffix is longer than name, hence name cannot end with suffix.
			 */
			return false;
		}
		return name.substring(i).equalsIgnoreCase(suffix);
	}