cleans a string of quotes and leading and trailing spaces, option: removes all spaces
769237
function cleanStr(s, rs){ //(s: string (string), rs: remove spaces (bool))
	if(s){
		s = s.replace(/"/g, '').trim();
		if(rs) s = s.replace(/ /g, '');
	}
	return s;
}
992031
def clean(ctx, text):
    
    text = conversions.to_string(text, ctx)
    return ''.join([c for c in text if ord(c) >= 32])
76304
static String sanitize(String string) {
        return WHITESPACE.matcher(string.trim()).replaceAll(DASH);
    }
1140949
String cleanOutputWhitespace(String str) {
		StringBuilder sb = new StringBuilder(str.length());

		int currentWhitespaceStart = -1;
		int startOfLine = 0;

		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);

			boolean isInlineWhitespace = c == ' ' || c == '\t';

			if (isInlineWhitespace && currentWhitespaceStart == -1)
				currentWhitespaceStart = i;

			if (!isInlineWhitespace) {
				if (c != '\n' && currentWhitespaceStart > 0 && currentWhitespaceStart != startOfLine) {
					sb.append(' ');
				}
				currentWhitespaceStart = -1;
			}

			if (c == '\n')
				startOfLine = i + 1;

			if (!isInlineWhitespace)
				sb.append(c);
		}

		return sb.toString();
	}
833954
def markup(str, remove_para = false)
      return '' unless str

      # Convert leading comment markers to spaces, but only if all non-blank
      # lines have them
      if str =~ /^(?>\s*)[^\#]/ then
        content = str
      else
        content = str.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }
      end

      res = formatter.convert content

      if remove_para then
        res.sub!(/^<p>/, '')
        res.sub!(/<\/p>$/, '')
      end

      res
    end
197537
public static String removeQuotes(String string, boolean trim) {
	if (string == null) return string;
	if (trim) string = string.trim();
	if (string.length() < 2) return string;

	if ((StringUtil.startsWith(string, '"') && StringUtil.endsWith(string, '"')) || (StringUtil.startsWith(string, '\'') && StringUtil.endsWith(string, '\''))) {
	    string = string.substring(1, string.length() - 1);
	    if (trim) string = string.trim();
	}
	return string;
    }
570982
def _clean_text(self, text):
        
        clean = []
        for char in text:
            if char in self.punc_stops:
                clean += '.'
            elif char not in self.punc:
                clean += char
            else:
                pass
        return (''.join(clean)).lower()
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
369190
def clean_whitespace(string, compact=False):
    """"""
    for a, b in (('\r\n', '\n'), ('\r', '\n'), ('\n\n', '\n'),
                 ('\t', ' '), ('  ', ' ')):
        string = string.replace(a, b)
    if compact:
        for a, b in (('\n', ' '), ('[ ', '['),
                     ('  ', ' '), ('  ', ' '), ('  ', ' ')):
            string = string.replace(a, b)
    return string.strip()
1362812
def delete_whitespaces(self, arg):
        
        # Deletes whitespaces after a newline
        arg = re.sub(re_newline_spc, '', arg)
        # Deletes every whitespace, tabulator, newline at the beginning of the string
        arg = re.sub(re_starting_whitespc, '', arg)
        # Deletes whitespace or tabulator if followed by whitespace or tabulator
        arg = re.sub(re_multi_spc_tab, '', arg)
        #  Deletes newline if it is followed by an other one
        arg = re.sub(re_double_newline, '', arg)
        # Deletes newlines and whitespaces at the end of the string
        arg = re.sub(re_ending_spc_newline, '', arg)
        return arg
1010058
function cleanCode(str) {
  str = str
    .replace(/\r\n|[\r\n\u2028\u2029]/g, '\n') // unify linebreaks
    .replace(/^\uFEFF/, ''); // replace zero-width no-break space

  str = stripFnStart(str) // replace function declaration
    .replace(/\)\s*\)\s*$/, ')') // replace closing paren
    .replace(/\s*};?\s*$/, ''); // replace closing bracket

  // Preserve indentation by finding leading tabs/spaces
  // and removing that amount of space from each line
  const spaces = str.match(/^\n?( *)/)[1].length;
  const tabs = str.match(/^\n?(\t*)/)[1].length;
  /* istanbul ignore next */
  const indentRegex = new RegExp(`^\n?${tabs ? '\t' : ' '}{${tabs || spaces}}`, 'gm');

  str = str.replace(indentRegex, '').trim();
  return str;
}
940955
def trim_whitespace(self, text):
        

        lines = text.split('\n')
        new_lines = [x.lstrip() for x in lines]

        return '\n'.join(new_lines)
1111090
function stripSpace() {
      if (hasTag && !nonSpace) {
        while (spaces.length) {
          tokens.splice(spaces.pop(), 1);
        }
      } else {
        spaces = [];
      }

      hasTag = false;
      nonSpace = false;
    }
695415
function strip_whitespace (s) {
      if (options.strip_whitespace) {
        return s.replace(/\s*\n/g,"\n").replace(/(\r?\n){2,}/g,"\n\n");
      }
      return s;
    }
892771
def _trim(self, somestr):
        
        tmp = RE_LSPACES.sub("", somestr)
        tmp = RE_TSPACES.sub("", tmp)
        return str(tmp)
1174286
function cleanseText( options, cb ) {
  return function( error, text ) {
    if ( !error ) {
      // clean up text
      text = util.replaceBadCharacters( text );

      if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) {
        if ( options.preserveOnlyMultipleLineBreaks ) {
          text = text.replace( STRIP_ONLY_SINGLE_LINEBREAKS, '$1 ' ).trim();
        }
        text = text.replace( WHITELIST_PRESERVE_LINEBREAKS, ' ' );
      } else {
        text = text.replace( WHITELIST_STRIP_LINEBREAKS, ' ' );
      }

      // multiple spaces, tabs, vertical tabs, non-breaking space]
      text = text.replace( / (?! )/g, '' )
        .replace( /[ \t\v\u00A0]{2,}/g, ' ' );

      text = entities.decode( text );
    }
    cb( error, text );
  };
}
599689
def clean_line(str, delimiter):
    """"""

    return [x.strip() for x in str.strip().split(delimiter) if x != '']