Remove superfluous whitespace characters from string.
177032
private function removeWhitespace(): void
    {
        $string = preg_replace('/ {2,}/', Tokens::SPACE, $this->normalisedString);
        $lines = [];

        foreach (explode(Tokens::LINE_FEED, $string) as $line) {
            if ('' !== $line = trim($line)) {
                $lines[] = $line;
            }
        }
        $this->normalisedString = implode(Tokens::LINE_FEED, $lines);
    }
125818
def fix_whitespace(line, offset, replacement):
    """"""
    # Replace escaped newlines too
    left = line[:offset].rstrip('\n\r \t\\')
    right = line[offset:].lstrip('\n\r \t\\')
    if right.startswith('#'):
        return line
    else:
        return left + replacement + right
265602
def string_matches_sans_whitespace(self, str1, str2_fuzzy_whitespace):
        """"""
        str2_fuzzy_whitespace = re.sub('\s+', '\s*', str2_fuzzy_whitespace)
        return re.search(str2_fuzzy_whitespace, str1) is not None
599689
def clean_line(str, delimiter):
    """"""

    return [x.strip() for x in str.strip().split(delimiter) if x != '']
289749
def remove_nullchars(block):
    """"""
    data = block.lstrip(b'\00')

    padding = b'\00' * ((len(block) - len(data)) % 8)

    return padding + data
1198842
def clean(cls, cpf):
        
        """
        if isinstance(cpf, six.string_types):
            cpf = int(re.sub('[^0-9]', '', cpf))

        return '{0:011d}'.format(cpf)
374394
def _remove_whitespace(text):
        """"""
        # while True:
        #     old_text = text
        #     text = text.replace('  ', ' ')
        #     if text == old_text:
        #         return text
        non_spaces = re.finditer(r'[^ ]', text)

        if not non_spaces:
            return text

        first_non_space = non_spaces.next()
        first_non_space = first_non_space.start()

        last_non_space = None
        for item in non_spaces:
            last_non_space = item

        if not last_non_space:
            return text[first_non_space:]
        else:
            last_non_space = last_non_space.end()
            return text[first_non_space:last_non_space]
1338849
def skip_whitespace(self, newlines=0):
        
        if newlines:
            while not self.eos:
                if self.get_char().isspace():
                    self.eat_length(1)
                else:
                    break
        else:
            char = ''
            while not self.eos:
                char = self.get_char()
                if char.isspace() and char != '\n':
                    self.eat_length(1)
                else:
                    break
849809
private String cleanAndTrimString(String text, int maxTextLength) {
        if (StringUtils.isNotBlank(text)) {
            String cleaned = text.trim().replaceAll("[\\s]+", " ");
            return cleaned.length() <= maxTextLength
                    ? cleaned
                    : cleaned.substring(0, maxTextLength) + " ...";
        }
        return text;
    }
437562
public static void normalizeAndCollapseWhitespace(final StringBuilder strBuffer) {
        WhiteSpaceState currentState = WhiteSpaceState.WORD;
        for (int i = strBuffer.length() - 1; i >= 0; i--) {
            final char currentChar = strBuffer.charAt(i);
            if (Character.isWhitespace(currentChar)) {
                if (currentState == WhiteSpaceState.SPACE) {
                    strBuffer.delete(i, i + 1);
                } else if (currentChar != ' ') {
                    strBuffer.replace(i, i + 1, " ");
                }
                currentState = WhiteSpaceState.SPACE;
            } else {
                currentState = WhiteSpaceState.WORD;
            }
        }
    }
319722
public static String suppressWhiteSpace(String str) {
	int len = str.length();
	StringBuilder sb = new StringBuilder(len);
	// boolean wasWS=false;

	char c;
	char buffer = 0;
	for (int i = 0; i < len; i++) {
	    c = str.charAt(i);
	    if (c == '\n' || c == '\r') buffer = '\n';
	    else if (isWhiteSpace(c)) {
		if (buffer == 0) buffer = c;
	    }
	    else {
		if (buffer != 0) {
		    sb.append(buffer);
		    buffer = 0;
		}
		sb.append(c);
	    }
	    // sb.append(c);
	}
	if (buffer != 0) sb.append(buffer);

	return sb.toString();
    }
457711
def clean_str(string):
    
    string = re.sub(r"[^A-Za-z0-9(),!?\'\`]", " ", string)
    string = re.sub(r"\'s", " \'s", string)
    string = re.sub(r"\'ve", " \'ve", string)
    string = re.sub(r"n\'t", " n\'t", string)
    string = re.sub(r"\'re", " \'re", string)
    string = re.sub(r"\'d", " \'d", string)
    string = re.sub(r"\'ll", " \'ll", string)
    string = re.sub(r",", " , ", string)
    string = re.sub(r"!", " ! ", string)
    string = re.sub(r"\(", r" \( ", string)
    string = re.sub(r"\)", r" \) ", string)
    string = re.sub(r"\?", r" \? ", string)
    string = re.sub(r"\s{2,}", " ", string)
    return string.strip().lower()
65552
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xa0', '')
		string = string.strip()
		return string
1084937
public void removeTrailingWhitespaces()
    {
        int last = -1;
        for (int i = text.length() - 1; i >= 0; i--)
        {
            if (isWhitespace(text.charAt(i)))
                last = i;
            else
                break;
        }
        if (last != -1)
        {
            text = text.substring(0, last);
            textStart = 0;
            textEnd = last;
        }
    }
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();
    }
1148052
def strip_accents(s, encoding= 'utf-8'):
    """"""
    if sys.version < '3':
        if isinstance(s,unicode):
           return unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore')
        else:
           return unicodedata.normalize('NFKD', unicode(s,encoding)).encode('ASCII', 'ignore')
    else:
        if isinstance(s,bytes): s = str(s,encoding)
        return str(unicodedata.normalize('NFKD', s).encode('ASCII', 'ignore'),'ascii')
563277
def clean_whitespace(statement):
    
    import re

    # Replace linebreaks and tabs with spaces
    statement.text = statement.text.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ')

    # Remove any leeding or trailing whitespace
    statement.text = statement.text.strip()

    # Remove consecutive spaces
    statement.text = re.sub(' +', ' ', statement.text)

    return statement