Cleans up the string given and applies the thousands delimiter Doesn't take into account chinese and indian locales with non-standard grouping This will be addressed in INSTUI-996
344760
function _format (input, locale) {
  locale = locale || Locale.browserLocale() // eslint-disable-line no-param-reassign

  let result = input

  const { thousands, decimal } = Decimal.getDelimiters(locale)
  const isNegative = (result[0] === '-')

  // remove all characters except for digits and decimal delimiters
  result = result.replace(new RegExp(`[^\\d\\${decimal}]`, 'g'), '')

  // remove all decimal delimiters except for the last one if present
  result = result.replace(new RegExp(`[${decimal}](?=.*[${decimal}])`, 'g'), '')

  // remove the leading zeros using positive lookahead
  result = result.replace(new RegExp(`^[0${thousands}]+(?=\\d|0${decimal})`, ''), '')

  // add leading zero to decimal, if not present
  result = result.charAt(0) === decimal ? result.replace(/^/, '0') : result

  const parts = result.split(decimal)
  const thousandSections = []

  let curr = parts[0]
  while (curr.length > 0) {
    thousandSections.unshift(curr.substr(Math.max(0, curr.length - 3), 3))
    curr = curr.substr(0, curr.length - 3)
  }

  result = thousandSections.join(thousands)

  if (parts[1]) {
    result = `${result}${decimal}${parts[1]}`
  }

  if (isNegative && result) {
    result = `-${result}`
  }

  return result
}
360312
private static String format(String x) {
		int z = x.indexOf("."); // 取小数点位置
		String lstr = "", rstr = "";
		if (z > -1) { // 看是否有小数，如果有，则分别取左边和右边
			lstr = x.substring(0, z);
			rstr = x.substring(z + 1);
		} else {
			// 否则就是全部
			lstr = x;
		}

		String lstrrev = StrUtil.reverse(lstr); // 对左边的字串取反
		String[] a = new String[5]; // 定义5个字串变量来存放解析出来的叁位一组的字串

		switch (lstrrev.length() % 3) {
		case 1:
			lstrrev += "00";
			break;
		case 2:
			lstrrev += "0";
			break;
		}
		String lm = ""; // 用来存放转换後的整数部分
		for (int i = 0; i < lstrrev.length() / 3; i++) {
			a[i] = StrUtil.reverse(lstrrev.substring(3 * i, 3 * i + 3)); // 截取第一个叁位
			if (!a[i].equals("000")) { // 用来避免这种情况：1000000 = one million
										// thousand only
				if (i != 0) {
					lm = transThree(a[i]) + " " + parseMore(String.valueOf(i)) + " " + lm; // 加:
																							// thousand、million、billion
				} else {
					lm = transThree(a[i]); // 防止i=0时， 在多加两个空格.
				}
			} else {
				lm += transThree(a[i]);
			}
		}

		String xs = ""; // 用来存放转换後小数部分
		if (z > -1) {
			xs = "AND CENTS " + transTwo(rstr) + " "; // 小数部分存在时转换小数
		}

		return lm.trim() + " " + xs + "ONLY";
	}
557459
def _normalize_string(raw_str):
  
  return " ".join(
      token.strip()
      for token in tokenizer.encode(text_encoder.native_to_unicode(raw_str)))
970621
def _apply_single(self, string):
        
        if string is None:
            return None
        result = self.trans_map.transliterate(string)
        result = self.SPACES_REGEX.sub(u" ", result).strip()
        return result
1323201
def fix_international(text):
    ""
    class SmartInternational(str):
        def __new__(cls, text):
            return str.__new__(cls, text)

        def endswith(self, string):
            return super(SmartInternational, self).endswith(str(string))
    if PY3:
        return text
    out = []
    last = 0
    for match in re.finditer(r'(?<=[^\\])(?:\\x[0-9a-f]{2}|\\u[0-9a-f]{4})', text):
        start, end, group = match.start(), match.end(), match.group()
        out.append(text[last:start])
        c = group.decode('unicode_escape')
        out.append(c if ord(c) > 160 and ord(c) != 173 else group)
        last = end
    out.append(text[last:])
    return SmartInternational(''.join(out).encode('utf-8'))
193594
def split_thousands(s):
    
    # Check input #
    if s is None: return "0"
    # If it's a string #
    if isinstance(s, basestring): s = float(s)
    # If it's a float that should be an int #
    if isinstance(s, float) and s.is_integer(): s = int(s)
    # Use python built-in #
    result = "{:,}".format(s)
    # But we want single quotes #
    result = result.replace(',', "'")
    # Return #
    return result
978118
def cleanString(someText):
    
    ret = ''
    if someText is not None:
        ret = filter(unicode.isalnum, someText.lower())
    return ret
365052
def format_data(self, value):
        
        s = locale.format_string('%1.10e', (value,))
        return self.fix_minus(s)
802151
def remove_non_latin(input_string, also_keep=None):
    
    if also_keep:
        also_keep += [' ']
    else:
        also_keep = [' ']
    latin_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    latin_chars += latin_chars.lower()
    latin_chars += ''.join(also_keep)
    no_latin = "".join([char for char in input_string if char in latin_chars])
    return no_latin
982028
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xb7', '')
		string = string.replace(u'\u0331', '')
		string = string.replace(u'\u0323', '')
		string = string.strip(' \n\rI.')
		return string
309217
def normalize_str(string):
    
    if string:
        if not isinstance(string, str):
            string = str(string, 'utf-8', 'replace')

        string = string.encode('utf-8')
        return normalize(
            'NFKD', string.decode('utf-8')).encode('ASCII', 'ignore').decode()
    return ''
136394
function cleanUpTitle(rawTitleString) {
    /*dashChar is most commonly the dash of the title string, or a
  the first repeating character surrounding the title */
    var dashChar = rawTitleString.charAt(0);
    //beginning and ending index of the dash
    var dashBegIndex = 0;
    var dashEndIndex = rawTitleString.lastIndexOf(dashChar);

    //loop through to find indicies without continous dashes
    while (rawTitleString.charAt(dashBegIndex) === (dashChar || '\n')) {
        dashBegIndex++;
    }
    while (rawTitleString.charAt(dashEndIndex) === (dashChar || '\n')) {
        dashEndIndex--;
    }

    var titleString = rawTitleString.slice(dashBegIndex + 1, dashEndIndex - 1);
    titleString = trimStringEnds(titleString, ['\n', '-']);
    return titleString;
}
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);
		}
137957
static String decamelize(String s) {
        return s.replaceAll("(\\p{javaLetterOrDigit})(\\p{javaUpperCase}\\p{javaLowerCase})","$1_$2")
                .replaceAll("(\\p{javaLowerCase})(\\p{javaUpperCase})","$1_$2")
                .toLowerCase(Locale.ENGLISH);
    }
243703
def _formatNumbers(self, line):
        
        # below thousands separator syntax only works for
        # python 2.7, skip for 2.6
        if sys.version_info < (2, 7):
            return line

        last_index = 0
        try:
            # find the index of the last } character
            last_index = (line.rindex('}') + 1)
            end = line[last_index:]
        except ValueError:
            return line
        else:
            # split the string on numbers to isolate them
            splitted = re.split("(\d+)", end)
            for index, val in enumerate(splitted):
                converted = 0
                try:
                    converted = int(val)
                # if it's not an int pass and don't change the string
                except ValueError:
                    pass
                else:
                    if converted > 1000:
                        splitted[index] = format(converted, ",d")
            return line[:last_index] + ("").join(splitted)
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;
}
702341
def _clean_for_xml(data):
    

    # If data is None or an empty string, don't bother
    if data:
        # This turns a string like "Hello…" into "Hello&#8230;"
        data = data.encode("ascii", "xmlcharrefreplace").decode("ascii")
        # However it's still possible that there are invalid characters in the string,
        # so simply remove any of those characters
        return _illegal_xml_chars_re.sub("", data)
    return data