Removes all characters which appear in string bag from string s.
347080
public static String stripCharsInBag(String s, String bag) {
        int i;
        String returnString = "";

        // Search through string's characters one by one.
        // If character is not in bag, append to returnString.
        for (i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            if (bag.indexOf(c) == -1) returnString += c;
        }
        return returnString;
    }
792709
protected String trim(String s) {
        if (s == null || s.length() == 0)
            return s;

        return s.trim();
    }
1276812
function trim( str, chr ){
	if ( !chr ){
		chr = '\\s';
	}
	return str.replace( new RegExp('^'+chr+'+|'+chr+'+$','g'), '' );
}
979577
def cleanup_formatted_string(cls, formatted_string):
        
        # Remove whitespace
        result = formatted_string.replace(' ', '')
        # Remove any static token parentheses
        result = re.sub(settings.REGEX_PARENTHESIS, '', result)
        # Remove any multiple separator characters
        multi_character_matches = re.finditer('[%s]{2,}' % settings.SEPARATORS, result)
        for multi_character_match in sorted(multi_character_matches, key=lambda x: len(x.group()), reverse=True):
            match = multi_character_match.group()
            most_common_separator = Counter(list(multi_character_match.group())).most_common(1)[0][0]
            result = result.replace(match, most_common_separator)
        # Remove trailing or preceding non letter characters
        result = re.sub(settings.REGEX_ADJACENT_UNDERSCORE, '', result)
        #  not sure what this one was...but certainly not it.
        result = re.sub(settings.REGEX_SINGLE_PARENTHESIS, '', result)
        return result
906766
public static String sanitize(String s) {
        if (s != null) {
            StringBuilder b = new StringBuilder(s.length());
            for (int i = 0, count = s.length(); i < count; i++) {
                char c = s.charAt(i);
                switch (c) {
                case '<':
                    b.append("&lt;");
                    break;
                case '>':
                    b.append("&gt;");
                    break;
                case '\'':
                    b.append("&#39;");
                    break;
                case '"':
                    b.append("&quot;");
                    break;
                case '&':
                    b.append("&amp;");
                    break;
                default:
                    b.append(c);
                }
            }
            return b.toString();
        }
        return "";
    }
1300272
static String removeExtraneousSlashes(String s) {
    int lastNonSlash = NON_SLASH_MATCHER.lastIndexIn(s);
    if (lastNonSlash != -1) {
      s = s.substring(0, lastNonSlash + 1);
    }

    return SLASH_MATCHER.collapseFrom(s, '/');
  }
1008817
public static String trimAllWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder sb = new StringBuilder(str);
        int index = 0;
        while (sb.length() > index) {
            if (Character.isWhitespace(sb.charAt(index))) {
                sb.deleteCharAt(index);
            }
            else {
                index++;
            }
        }
        return sb.toString();
    }
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;
    }
892346
def remove_escapes(self):
        
        chars = []

        i = 0
        while i < len(self.string):
            char = self.string[i]
            if char == "\\":
                i += 1
            else:
                chars.append(char)

            i += 1

        return "".join(chars)
1000417
public static String sanitize(String s) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); ++i) {
			char c = s.charAt(i);
			switch (c) {
			case '\u00c0':
			case '\u00c1':
			case '\u00c3':
			case '\u00c4':
				sb.append('A');
				break;
			
			case '\u00c8':
			case '\u00c9':
			case '\u00cb':
				sb.append('E');
				break;
			
			case '\u00cc':
			case '\u00cd':
			case '\u00cf':
				sb.append('I');
				break;
			
			case '\u00d2':
			case '\u00d3':
			case '\u00d5':
			case '\u00d6':
				sb.append('O');
				break;
			
			case '\u00d9':
			case '\u00da':
			case '\u00dc':
				sb.append('U');
				break;
			
			case '\u00e0':
			case '\u00e1':
			case '\u00e3':
			case '\u00e4':
				sb.append('a');
				break;
			
			case '\u00e8':
			case '\u00e9':
			case '\u00eb':
				sb.append('e');
				break;
			
			case '\u00ec':
			case '\u00ed':
			case '\u00ef':
				sb.append('i');
				break;
			
			case '\u00f2':
			case '\u00f3':
			case '\u00f6':
			case '\u00f5':
				sb.append('o');
				break;
			
			case '\u00f9':
			case '\u00fa':
			case '\u00fc':
				sb.append('u');
				break;
			
			case '\u00d1':
				sb.append('N');
				break;
			
			case '\u00f1':
				sb.append('n');
				break;
			
			case '\u010c':
				sb.append('C');
				break;
			
			case '\u0160':
				sb.append('S');
				break;
			
			case '\u017d':
				sb.append('Z');
				break;
			
			case '\u010d':
				sb.append('c');
				break;
			
			case '\u0161':
				sb.append('s');
				break;
			
			case '\u017e':
				sb.append('z');
				break;
			
			case '\u00df':
				sb.append("ss");
				break;
			
			default:
				if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
						(c >= '0' && c <= '9')) {
					sb.append(c);
				} else {
					sb.append('_');
				}
				break;
			}
		}
		return sb.toString();
	}
1210313
public static String removeSimpleQuotes(String s) {
        if (s.startsWith("'") && s.endsWith("'")) {
            return s.substring(1, s.length() - 1);
        }
        return s;

    }
1224535
def cleanup_strings(strings, strip: true)
      strings = Array(strings).flatten.map! { |s| cleanup_string(s, strip: strip) }
      strings.reject!(&:blank?)
      strings
    end
952371
def sanitize(string, ignore_characters=None):
    
    # only deal with strings
    if string is None:
        return

    ignore_characters = ignore_characters or set()

    # replace some characters with one space
    characters = {'-', ':', '(', ')', '.'} - ignore_characters
    if characters:
        string = re.sub(r'[%s]' % re.escape(''.join(characters)), ' ', string)

    # remove some characters
    characters = {'\''} - ignore_characters
    if characters:
        string = re.sub(r'[%s]' % re.escape(''.join(characters)), '', string)

    # replace multiple spaces with one
    string = re.sub(r'\s+', ' ', string)

    # strip and lower case
    return string.strip().lower()
1360104
public static String cleanString(String pStr) {
        if (pStr == null || pStr.equals("")) {
            return pStr;
        }
        StringBuffer buff = new StringBuffer();
        for (int i = 0; i < pStr.length(); i++) {
            char aChar = pStr.charAt(i);
            if (Character.isLetterOrDigit(aChar)) {
                buff.append(aChar);
            }
        }
        return buff.toString();
    }
622600
def CleanString(s):
    
    punc = (' ', '-', '\'', '.', '&amp;', '&', '+', '@')
    pieces = []
    for part in s.split():
        part = part.strip()
        for p in punc:
            part = part.replace(p, '_')
        part = part.strip('_')
        part = part.lower()
        pieces.append(part)
    return '_'.join(pieces)
671494
def clean(string):
    '''  '''
    # manual fixes in the source
    # 24/1.png
    # 9/1.png
    # 3/1.png
    #if ')' in string:  # fix in the source data
        #string = string.split(')')[0] + ')'  # remove trailing garbage
    return (string
            .replace('_', '')
            .replace('-', '')
            .replace('—', '')
            .replace('.', '')
            .replace('=', '')
            .replace('\u2018',"'")  # LEFT SINGLE QUOTATION MARK
            .replace('\u2019', "'")  # RIGHT SINGLE QUOTATION MARK
            .strip())
87669
private static String cleanString(String str)
    {
	String result = str;
	result = result.replace("\r", "");
	result = result.replace("\n", "");
	result = result.replace("\t", "");

	return result;
    }