Removes one character at a time from the text until its width or
height is beneath the passed-in max param.
559979
function truncate(target, maxHeight) {
        if (!maxHeight) {
          return;
        }

        /**
         * Resets global variables.
         */
        function reset() {
          splitOnChars = opt.splitOnChars.slice(0);
          splitChar = splitOnChars[0];
          chunks = null;
          lastChunk = null;
        }

        var nodeValue = target.nodeValue.replace(opt.truncationChar, '');

        //Grab the next chunks
        if (!chunks) {
          //If there are more characters to try, grab the next one
          if (splitOnChars.length > 0) {
            splitChar = splitOnChars.shift();
          }
          //No characters to chunk by. Go character-by-character
          else {
            splitChar = '';
          }

          chunks = nodeValue.split(splitChar);
        }

        //If there are chunks left to remove, remove the last one and see if
        // the nodeValue fits.
        if (chunks.length > 1) {
          // console.log('chunks', chunks);
          lastChunk = chunks.pop();
          // console.log('lastChunk', lastChunk);
          applyEllipsis(target, chunks.join(splitChar));
        }
        //No more chunks can be removed using this character
        else {
          chunks = null;
        }

        //Insert the custom HTML before the truncation character
        if (truncationHTMLContainer) {
          target.nodeValue = target.nodeValue.replace(opt.truncationChar, '');
          element.innerHTML = target.nodeValue + ' ' + truncationHTMLContainer.innerHTML + opt.truncationChar;
        }

        //Search produced valid chunks
        if (chunks) {
          //It fits
          if (element.clientHeight <= maxHeight) {
            //There's still more characters to try splitting on, not quite done yet
            if (splitOnChars.length >= 0 && splitChar !== '') {
              applyEllipsis(target, chunks.join(splitChar) + splitChar + lastChunk);
              chunks = null;
            }
            //Finished!
            else {
              return element.innerHTML;
            }
          }
        }
        //No valid chunks produced
        else {
          //No valid chunks even when splitting by letter, time to move
          //on to the next node
          if (splitChar === '') {
            applyEllipsis(target, '');
            target = getLastChild(element);

            reset();
          }
        }

        //If you get here it means still too big, let's keep truncating
        if (opt.animate) {
          setTimeout(function() {
            truncate(target, maxHeight);
          }, opt.animate === true ? 10 : opt.animate);
        } else {
          return truncate(target, maxHeight);
        }
      }
193166
function removeAnchors(text) {
        if(text.charAt(0) == '\x02')
            text = text.substr(1);
        if(text.charAt(text.length - 1) == '\x03')
            text = text.substr(0, text.length - 1);
        return text;
    }
258938
def remove(text, what, count=None, strip=False):
    '''
    
    '''
    return replace(text, what, '', count=count, strip=strip)
898339
public void clearLast(int N) {
        if (N < 1) {
            throw new IllegalArgumentException("Unable to clear " + N + " lines");
        }
        if (N > count()) {
            throw new IllegalArgumentException("Count: " + N + ", Size: " + count());
        }
        if (N == count()) {
            clear();
            return;
        }

        terminal.format("\r%s", CURSOR_ERASE);
        buffer.remove(buffer.size() - 1);
        for (int i = 1; i < N; ++i) {
            terminal.format("%s%s", UP, CURSOR_ERASE);
            buffer.remove(buffer.size() - 1);
        }

        terminal.format("%s\r%s",
                        UP,
                        cursorRight(printableWidth(lastLine())));
    }
1235275
private String cleanUpString(String text) {
    if (StringUtils.isEmpty(text)) {
      return text;
    }
    else {
      return CONTROL_CHARS.matcher(text).replaceAll("");
    }
  }
632872
private synchronized void trim() {
        while (currentSize > sizeLimit) {
            Bitmap bitmap = bitmapsByLastUse.remove(0);
            bitmapsBySize.remove(bitmap);
            currentSize -= getBitmapSize(bitmap);
        }
    }
322857
function stripBOM( content ) {
    if( Buffer.isBuffer( content ) && content.length >= 2 && content[0] === 0xFE && content[1] === 0xFF ) {
        content = content.slice( 2 );
    } else if( typeof content === 'string' && content.charCodeAt( 0 ) === 0xFEFF ) {
        content = content.slice( 1 );
    }

    return content;
}
761054
function truncate(str, len) {
        // Truncate text to specified length
        if (str.length > len) {
            str = str.substr(0, len);

            // To prevent awkwardly truncating in the middle of a word,
            // attempt to truncate at the end of the last whole word
            var lastSpaceChar = str.lastIndexOf(" ");
            if (lastSpaceChar < len && lastSpaceChar > -1) {
                str = str.substr(0, lastSpaceChar);
            }
            return str;
        }
    }
1305314
def _clean_text(self, text):
        """"""
        output = []
        for char in text:
            cp = ord(char)
            if cp in (0, 0xfffd) or self._is_control(char):
                continue
            if self._is_whitespace(char):
                output.append(' ')
            else:
                output.append(char)
        return ''.join(output)
992031
def clean(ctx, text):
    
    text = conversions.to_string(text, ctx)
    return ''.join([c for c in text if ord(c) >= 32])
962691
def truncate(str, len = 80)
      if str and str.length > len and (add = str[len..-1].index(' '))
        str = str[0, len + add] + '&#8230;'
      end
      str
    end
895756
function truncateString(str, max) {

  str = str != null ? str : ''
  str = String(str)

  if(max == Infinity) return str

  var i = 0
  var wwidth = 0
  while (i < str.length) {
    var w = wcwidth(str.charAt(i))
    if(w + wwidth > max)
      break
    wwidth += w
    ++i
  }
  return str.slice(0, i)
}
1264917
def removeSpacePadding(str, blocksize=AES_blocksize):
    '' 
    pad_len = 0    
    for char in str[::-1]: # str[::-1] reverses string
        if char == ' ':
            pad_len += 1
        else:
            break

    str = str[:-pad_len]
   
    return str
553227
public static String trim(String s, int maxWidth) {
    if (s.length() <= maxWidth) {
      return (s);
    }
    return (s.substring(0, maxWidth));
  }
1057645
def trim(self):
        
        if self.hasText():
            self.text = self.text.trim()
        return self
685034
def truncate(string, width, options={})
      trailing = options[:trailing] || '…'

      chars = string.to_s.chars.to_a
      if chars.length < width && chars.length > 3
        chars.join
      elsif chars.length > 3
        (chars[0, width - trailing.length].join) + trailing
      end
    end
1016056
def _delete_horizontal_space(text, pos):
    """"""
    while pos > 0 and text[pos - 1].isspace():
        pos -= 1
    end_pos = pos
    while end_pos < len(text) and text[end_pos].isspace():
        end_pos += 1
    return text[:pos] + text[end_pos:], pos