Removes the trailing delimiter from a string.

@param str String to process.
@param delimiter Delimiter to remove.
@return The string with the trailing delimiter removed.
359291
public static String removeTrailingDelimiter(String str, String delimiter) {
        if (!str.endsWith(delimiter)) {
            return str;
        } else {
            return str.substring(0, str.length() - delimiter.length());
        }
    }
57968
public String trimLeading(String str) {
        if (str == null) {
            return null;
        }

        int length = str.length();
        for (int i=0; i<length; i++) {
            if (str.charAt(i) > ' ') {
                return str.substring(i);
            }
        }

        return "";
    }
799901
public static List<String> split(
                    final String str
                    )
    {
        String  s = str;
        if (s != null) {
            s = s.trim();
        }

        List<String>  list = new ArrayList<String>();
        if (s == null || s.length() == 0) {
            return list;
        }

        String[]  tokens = s.split( "[ \t\n\r\f]" );
        // NOTE: tokens[i] may be an empty string "".

        // excludes empty strings.
        int  n_tokens = tokens.length;
        for (int  i = 0; i < n_tokens; i++) {
            if (tokens[i].length() > 0) {
                list.add( tokens[i] );
            }
        }

        return list;
    }
1362853
function trim(str, targetStr) {
    var retStr = "";
    var regStr;

    if (typeof str != "string") {
        return retStr;
    }

    if (typeof targetStr != "string" || !targetStr) {
        targetStr = "\\s";
    }

    regStr = "^" + targetStr + "*(.*?)" + targetStr + "*$";
    regStr = new RegExp(regStr);

    str = str.replace(regStr, "$1");
    return str;
}
558137
public static String stripAccents(final String str) {
        if (N.isNullOrEmpty(str)) {
            return str;
        }

        final String decomposed = Normalizer.normalize(str, Normalizer.Form.NFD);
        // Note that this doesn't correctly remove ligatures...
        return pattern_accent.matcher(decomposed).replaceAll("");//$NON-NLS-1$
    }
523758
public static String replaceBlank(String str) {
        Matcher m = BLANK_PATTERN.matcher(str);
        return m.replaceAll("").replaceAll("\\s{2,}", " ").trim();
    }
1355863
public static boolean isDelimiter(String str)
    {
        if (str != null && ("-".equals(str) || "－".equals(str)))
            return true;
        else
            return false;
    }
98013
private String trim(final String str) {

        final int length = str.length();
        if(length == 0) {
            return str;
        }

        if(leftAlign) {
            if(str.charAt(0) != trimChar) {
                // 左端がトリム対象の文字出ない場合、処理終了
                return str;

            }

            // 左側から、trimCharに一致しない位置を探す
            for(int i=0; i < length; i++) {
                char c = str.charAt(i);
                if(c != trimChar) {
                    return str.substring(i);
                }
            }

            // 全ての文字がトリム対象の場合
            return "";

        } else {
            if(str.charAt(length - 1) != trimChar) {
                // 右端がトリム対象の文字出ない場合、処理終了
                return str;

            }

            // 右側から、trimCharに一致しない位置を探す
            for(int i=length - 1; i >= 0; i--) {
                char c = str.charAt(i);
                if(c != trimChar) {
                    return str.substring(0, i + 1);
                }
            }

            // 全ての文字がトリム対象の場合
            return "";

        }

    }
614170
public static String truncate(String str, int count)
    {
        if(count < 0 || str.length() <= count)
            return str;

        int pos = count;
        for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
        return str.substring(0, pos)+"...";
    }
1163117
public String trimTrailing(String str) {
        if (str == null) {
            return null;
        }

        int length = str.length();
        for (int i=length-1; i>=0; i--) {
            if (str.charAt(i) > ' ') {
                return str.substring(0, i + 1);
            }
        }

        return "";
    }
854881
public static String removeLeadingAndTrailingDelimiter(String str, String delimiter) {
        final int strLength = str.length();
        final int delimiterLength = delimiter.length();

        final boolean leadingDelimiter = str.startsWith(delimiter);
        final boolean trailingDelimiter = strLength > delimiterLength && str.endsWith(delimiter);
        if (!leadingDelimiter && !trailingDelimiter) {
            return str;
        } else {
            final int startingDelimiterIndex = leadingDelimiter ? delimiterLength : 0;
            final int endingDelimiterIndex = trailingDelimiter ? Math.max(strLength - delimiterLength, startingDelimiterIndex) : strLength;
            return str.substring(startingDelimiterIndex, endingDelimiterIndex);
        }
    }
313443
private static String delimit(String s, char c) {
    int i = s.indexOf(c);
    while (i != -1) {
      if (i == 0 || s.charAt(i - 1) != '\\') {
        s = s.substring(0, i) + '\\' + s.substring(i);
        i = s.indexOf(c, i + 2);
      } else {
        i = s.indexOf(c, i + 1);
      }
    }
    return s;
  }
1306222
public static function slugify($str, $delimiter = '-')
    {
        $temp = preg_replace(
            '/[^a-z0-9]/',
            $delimiter,
            strtolower(trim(strip_tags($str)))
        );

        return preg_replace('/-{2,}/', $delimiter, $temp);
    }
709789
private static final String escape(String str) {
        if (str == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder(str.length() * 2);
        int len = str.length();
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            switch (c) {
                case TOKEN_DELIM:
                case USER_DATA_DELIM:
                case USER_ATTRIB_DELIM:
                    sb.append('\\');
                    break;
                default:
                    break;
            }
            sb.append(c);
        }
        return sb.toString();
    }
726812
public static String trimAllWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        int index = 0;
        while (buf.length() > index) {
            if (Character.isWhitespace(buf.charAt(index))) {
                buf.deleteCharAt(index);
            } else {
                index++;
            }
        }
        return buf.toString();
    }
462982
public static String trimWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0))) {
            buf.deleteCharAt(0);
        }
        while (buf.length() > 0 && Character.isWhitespace(buf.charAt(buf.length() - 1))) {
            buf.deleteCharAt(buf.length() - 1);
        }
        return buf.toString();
    }
434283
protected final String shaveOffNonJavaIdentifierStartChars( String str ) {
      String str2 = str;
      // shave off first char if not valid
      boolean ready = false;
      while( !ready ){
         if( !Character.isJavaIdentifierStart( str2.charAt( 0 ) ) ){
            str2 = str2.substring( 1 );
            if( str2.length() == 0 ){
               throw new JSONException( "Can't convert '" + str + "' to a valid Java identifier" );
            }
         }else{
            ready = true;
         }
      }
      return str2;
   }