Removes the middle part of any string over maxlen characters.
356418
def truncate_str(str_, maxlen=110, truncmsg=' ~~~TRUNCATED~~~ '):
    
    if NO_TRUNCATE:
        return str_
    if maxlen is None or maxlen == -1 or len(str_) < maxlen:
        return str_
    else:
        maxlen_ = maxlen - len(truncmsg)
        lowerb  = int(maxlen_ * .8)
        upperb  = maxlen_ - lowerb
        tup = (str_[:lowerb], truncmsg, str_[-upperb:])
        return ''.join(tup)
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);
        }
    }
359291
public static String removeTrailingDelimiter(String str, String delimiter) {
        if (!str.endsWith(delimiter)) {
            return str;
        } else {
            return str.substring(0, str.length() - delimiter.length());
        }
    }
378600
public static String 
    trimRight( String string ) 
    {
    	for( int i = string.length(); i > 0; --i )
    	{
    		if( string.charAt(i-1) != ' '
    		&& string.charAt(i-1) != '\t'
    		&& string.charAt(i-1) != '\n'
    		&& string.charAt(i-1) != '\r' ) 
    		{    			
    			return i == string.length() ? string : 
    			                              string.substring( 0, i );
    		}
    	}
    	return "";
    }
261285
protected function removeBadCharFirst( $string ) {
		if ( $string != '' ) {
			$char = ord( $string[0] );
			if ( $char >= 0x80 && $char < 0xc0 ) {
				# We chopped in the middle of a character; remove the whole thing
				$string = preg_replace( '/^[\x80-\xbf]+/', '', $string );
			}
		}
		return $string;
	}
100416
private String trim(String string) {

		while (string.startsWith("\"") && string.endsWith("\"")) {

			string = string.substring(1, string.length() - 1);
		}
		return string;
	}
686937
def _clean_str(self, s):
        
        return s.translate(str.maketrans('', '', punctuation)).replace('\u200b', " ").strip().lower()
747100
public static String truncate(String str, int maxSize) {
        if (str == null) {
            return null;
        }

        if (str.length() <= maxSize) {
            return str;
        }

        return str.substring(0, maxSize);
    }
924688
function trimLeading(text, prefix) {
        if (text && prefix) {
            if (_.startsWith(text, prefix) || text.indexOf(prefix) === 0) {
                return text.substring(prefix.length);
            }
        }
        return text;
    }
489962
function truncate(str, maxLength) {
	maxLength = maxLength || 300;

	if (str.length > maxLength) {
		var index = str.indexOf('>');
		str = str.substring(0, index + 1);
	}

	return str;
}
216536
public static String truncate(String string, int maxBytesLength,
            String appendString) {
        return string.getBytes().length > maxBytesLength ? truncate(string,
                maxBytesLength - appendString.getBytes().length) + appendString
                : string;
    }
657637
function(string, maxLength) {
            if (!string) return string;
            if (maxLength < 1) return string;
            if (string.length <= maxLength) return string;
            if (maxLength == 1) return string.substring(0,1) + '...';

            var midpoint = Math.ceil(string.length / 2);
            var toremove = string.length - maxLength;
            var lstrip = Math.ceil(toremove/2);
            var rstrip = toremove - lstrip;
            return string.substring(0, midpoint-lstrip) + '...' + string.substring(midpoint+rstrip);
        }
1114084
public static String removeTrailingZeros(final String str) {
    String result = str;
    if (str != null && str.length() != 0) {
      int endIndex = str.length();
      while (endIndex > 1) {
        final char ch = str.charAt(endIndex - 1);
        if (ch != '0') {
          break;
        }
        endIndex--;
      }
      if (endIndex < str.length()) {
        result = str.substring(0, endIndex);
      }
    }
    return result;
  }
978118
def cleanString(someText):
    
    ret = ''
    if someText is not None:
        ret = filter(unicode.isalnum, someText.lower())
    return ret
65552
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xa0', '')
		string = string.strip()
		return string
1336307
def clean_string(text):
    
    if isinstance(text, six.string_types):
        return text.translate(UNI_SPECIAL_CHARS).strip()
    return text.translate(None, STR_SPECIAL_CHARS).strip()
71343
public function cleanString()
		{
			//get rid of newline holders in values
			$this->processString = str_replace('\\\\\\\\n', ' ', $this->processString);

			//replace newline holders with newline
			$this->processString = str_replace('\n', "\n", $this->processString);

			//match returns extra curly bracket at EOL, get rid of it
			$this->processString = substr($this->processString, 0, -1);

			//convert unicode encoded characters to html entities hex
			$this->processString = preg_replace('/\\\\u([0-9a-fA-F]{4})/', '&#x$1;', $this->processString);

			//get rid of escapes added for javascript
			$this->processString = stripslashes($this->processString);
		}