function parseNumberRaw()

in runtime/shared/intlNumUtils.js [338:384]


function parseNumberRaw(
  text: string,
  decimalDelimiter: string,
  numberDelimiter: string = '',
): ?number {
  // Replace numerals based on current locale data
  const digitsMap = _getNativeDigitsMap();
  let _text = text;
  if (digitsMap) {
    _text = text
      .split('')
      .map((/*string*/ character) => digitsMap[character] || character)
      .join('')
      .trim();
  }

  _text = _text.replace(/^[^\d]*\-/, '\u0002'); // preserve negative sign
  _text = _text.replace(matchCurrenciesWithDots, ''); // remove some currencies

  const decimalExp = escapeRegex(decimalDelimiter);
  const numberExp = escapeRegex(numberDelimiter);

  const isThereADecimalSeparatorInBetween = _buildRegex(
    '^[^\\d]*\\d.*' + decimalExp + '.*\\d[^\\d]*$',
  );
  if (!isThereADecimalSeparatorInBetween.test(_text)) {
    const isValidWithDecimalBeforeHand = _buildRegex(
      '(^[^\\d]*)' + decimalExp + '(\\d*[^\\d]*$)',
    );
    if (isValidWithDecimalBeforeHand.test(_text)) {
      _text = _text.replace(isValidWithDecimalBeforeHand, '$1\u0001$2');
      return _parseCodifiedNumber(_text);
    }
    const isValidWithoutDecimal = _buildRegex(
      '^[^\\d]*[\\d ' + escapeRegex(numberExp) + ']*[^\\d]*$',
    );
    if (!isValidWithoutDecimal.test(_text)) {
      _text = '';
    }
    return _parseCodifiedNumber(_text);
  }
  const isValid = _buildRegex(
    '(^[^\\d]*[\\d ' + numberExp + ']*)' + decimalExp + '(\\d*[^\\d]*$)',
  );
  _text = isValid.test(_text) ? _text.replace(isValid, '$1\u0001$2') : '';
  return _parseCodifiedNumber(_text);
}