Strip the suffix from the string.

    If 'regex' is specified, suffix is understood as a regular expression.
160832
def strip_suffix(string, suffix, regex=False):
    """"""
    if not isinstance(string, six.string_types) or not isinstance(suffix, six.string_types):
        msg = 'Arguments to strip_suffix must be string types. Are: {s}, {p}'\
              .format(s=type(string), p=type(suffix))
        raise TypeError(msg)

    if not regex:
        suffix = re.escape(suffix)
    if not suffix.endswith('$'):
        suffix = '({s})$'.format(s=suffix)
    return _strip(string, suffix)
68106
def prefix(filename):
    '''  '''
    return os.path.split(re.sub(_afni_suffix_regex,"",str(filename)))[1]
238429
def _is_suffix(self, t):
        """"""
        return t not in NOT_SUFFIX and (t.replace('.', '') in SUFFIXES or t.replace('.', '') in SUFFIXES_LOWER)
510015
def replace_suffix(to_transform, suffix):
    
    if is_sequence(to_transform):
        transformed = []
        for f in to_transform:
            (base, _) = os.path.splitext(f)
            transformed.append(base + suffix)
        return transformed
    elif is_string(to_transform):
        (base, _) = os.path.splitext(to_transform)
        return base + suffix
    else:
        raise ValueError("replace_suffix takes a single filename as a string or "
                         "a list of filenames to transform.")
716276
private String stripPrefix(final String input, final String searchString) {
        return input.substring(searchString.length(), input.length()).trim();
    }
393498
private static String stripFileExtensionIfAny(final String name) {
        final int suffix = name.lastIndexOf(".html");
        return suffix == -1 ? name : name.substring(0, suffix);
    }
853746
public static function strip($str, $prefix, $suffix)
    {
        return self::rstrip(self::lstrip($str, $prefix), $suffix);
    }
1347151
public static String trim(String string)
  {
    if(string == null) {
      return null;
    }
    int length = string.length();
    int beginIndex = 0;
    for(; beginIndex < length; ++beginIndex) {
      if(!Character.isWhitespace(string.charAt(beginIndex))) break;
    }
    int endIndex = length - 1;
    for(; endIndex >= 0; --endIndex) {
      if(!Character.isWhitespace(string.charAt(endIndex))) break;
    }
    return string.substring(beginIndex, endIndex + 1);
  }
865356
def suffix?(suffix, text)
      len = suffix.length
      len <= text.length and suffix == text[-len, len]
    end
1182013
public static function removeSuffix($string, $suffix)
    {
        if (self::endsWith($string, $suffix)) {
            return mb_substr($string, 0, -mb_strlen($suffix));
        }
        return $string;
    }
597941
public static String strip(final String expression) {
        final String expr = StringUtils.trimToEmpty(expression);
        final Matcher matcher = DELIMITED_EXPR.matcher(expr);
        return matcher.matches() ? matcher.group(1) : expr;
    }
650774
def strip_prefix(string, prefix, regex=False):
    """"""
    if not isinstance(string, six.string_types) or not isinstance(prefix, six.string_types):
        msg = 'Arguments to strip_prefix must be string types. Are: {s}, {p}'\
              .format(s=type(string), p=type(prefix))
        raise TypeError(msg)

    if not regex:
        prefix = re.escape(prefix)
    if not prefix.startswith('^'):
        prefix = '^({s})'.format(s=prefix)
    return _strip(string, prefix)
921486
def clean(self, suffixes=None):
        
        if suffixes is None:
            suffixes = [DONE_SUFFIX, LOCK_SUFFIX, PART_SUFFIX]

        for suffix in suffixes:
            listing = self.working_context.get_listing(suffix)
            for filename in listing:
                self.working_context.remove(filename)
703785
def remove_trailing_string(content, trailing):
    
    if content.endswith(trailing) and content != trailing:
        return content[:-len(trailing)]
    return content
994633
public static function endsWith($str, $suffix)
    {
        return stripos($str, $suffix) === strlen($str) - strlen($suffix);
    }
57048
static String stripLeadingHyphens(String str)
    {
        if (str == null)
        {
            return null;
        }
        if (str.startsWith("--"))
        {
            return str.substring(2, str.length());
        }
        else if (str.startsWith("-"))
        {
            return str.substring(1, str.length());
        }

        return str;
    }
1221542
private function endswith($string, $suffix)
	{
		$strlen = strlen($string);
		$testlen = strlen($suffix);
		if ($testlen > $strlen) {
			return false;
		}

		return substr_compare($string, $suffix, -$testlen) === 0;
	}