Given a phone number, strip non-numeric characters for database storage
Note: If phone has extension, this is not a suitable function

@param {Number|String} phone
@returns {String}
773230
function sanitizePhone(phone: ?number | string): string {
  let newPhone = String(phone).replace(/\D/g, "");
  if (!newPhone) {
    return "";
  }

  if (String(newPhone)[0] !== "1" && newPhone.length === 10) {
    newPhone = `1${newPhone}`;
  }
  return newPhone;
}
887443
def _format_phone_number(self, value, attr):
        """"""
        strict_validation = self.get_field_value(
            'strict_phone_validation',
            default=False
        )
        strict_region = self.get_field_value(
            'strict_phone_region',
            default=strict_validation
        )
        region = self.get_field_value('region', 'US')
        phone_number_format = self.get_field_value(
            'phone_number_format',
            default=phonenumbers.PhoneNumberFormat.INTERNATIONAL
        )

        # Remove excess special chars, except for the plus sign
        stripped_value = re.sub(r'[^\w+]', '', value)

        try:
            if not stripped_value.startswith('+') and not strict_region:
                phone = phonenumbers.parse(stripped_value, region)
            else:
                phone = phonenumbers.parse(stripped_value)

            if (not phonenumbers.is_possible_number(phone) or
                    not phonenumbers.is_valid_number(phone) and
                    strict_validation):
                raise ValidationError(
                    "The value for {} ({}) is not a valid phone "
                    "number.".format(attr, value)
                )

            return phonenumbers.format_number(phone, phone_number_format)

        except phonenumbers.phonenumberutil.NumberParseException as exc:
            if strict_validation or strict_region:
                raise ValidationError(exc)
482275
function() {
	
      var str_value;
      
      // StringField getValue (handles typeInvite and trim options)
      str_value = inputEx.NumberField.superclass.getValue.call(this);
      
      // don't return NaN if empty field
      if (str_value === '') {
         return '';
      }
      
      return parseFloat(str_value);
   }
558597
function (num) {
  for (var ext = '', i = 0; i < 4; i++) {
    ext = String.fromCharCode(num & 0xFF) + ext
    num >>= 8
  }
  return ext
}
509912
def strip_non_ascii(string):
    ''' '''
    stripped = (c for c in string if 0 < ord(c) < 127)
    return ''.join(stripped)
990656
function toNumber(str, fallback) {
    if (typeof str === 'number') {
        return str;
    }
    if (REGEXP_NUMBER.test(str)) {
        return Number(str);
    }
    return fallback;
}
861139
function numberToString (x) { // avoids scientific notation for too large and too small numbers

    if (isString (x)) return x

    if (Math.abs (x) < 1.0) {
        const s = x.toString ()
        const e = parseInt (s.split ('e-')[1])
        const neg = (s[0] === '-')
        if (e) {
            x *= Math.pow (10, e-1)
            x = (neg ? '-' : '') + '0.' + (new Array (e)).join ('0') + x.toString ().substring (neg ? 3 : 2)
        }
    } else {
        let e = parseInt (x.toString ().split ('+')[1])
        if (e > 20) {
            e -= 20
            x /= Math.pow (10, e)
            x += (new Array (e+1)).join ('0')
        }
    }
    return x.toString ()
}
754205
function(str) {
            // determine if the string is a hex number by checking if it begins with '0x' or '-0x', in which case delegate to parseInt with a 16 radix
            if(/^( )*(0x|-0x)/.test(str)) {
                return parseInt(str, 16);
            }
            // if the number is not in decimal or scientific format, return NaN explicitly instead of letting JavaScript do its loose parsing
            if(!(/^[-+]?[0-9]*[.]?[0-9]*$/.test(str) || (/^[-+]?[0-9][.]?[0-9]*e[-+]?[1-9][0-9]*$/).test(str))) {
                return NaN;
            }
            return parseFloat(str);
        }
577608
function(number) {
      if (typeof number !== 'string') {
        throw new TypeError('cardNumber must be a string!');
      }

      var cardNumber = number.trim().replace(/\s/g, '');

      return new Card(cardNumber);
    }
273155
function (n) {
            var nybHexString = '0123456789ABCDEF';
            return (
                String(nybHexString.substr((n >> 4) & 0x0F, 1)) +
                String(nybHexString.substr(n & 0x0F, 1))
            );
        }
1288165
function pad (num, padLen) {
  var padding = '0000';
  num = String(num);
  return padding.substring(0, padLen - num.length) + num;
}
389491
function(value){
      return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
    }
701007
function(object) {
        var self = this
        if (object == undefined || object == null) return 'null'
        if (object === true) return 'true'
        if (object === false) return 'false'
        switch (typeof object) {
          case 'number': return object
          case 'string': return this.escapable.test(object) ?
            '"' + object.replace(this.escapable, function (a) {
              return typeof self.meta[a] === 'string' ? self.meta[a] :
                '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4)
            }) + '"' :
            '"' + object + '"'
          case 'object':  
            if (object.constructor == Array)
              return '[' + map(object, function(val){
                return self.encode(val)
              }).join(', ') + ']'
            else if (object)
              return '{' + map(object, function(key, val){
                return self.encode(key) + ':' + self.encode(val)
              }).join(', ') + '}'
        }
        return 'null'
      }
1185112
function readNumericString(s, minValue) {
    var length = readLength(s);
    length = (length + minValue + 1) / 2;
    s.readPadding(length);
}
764234
function formatNumbers(prevParams, decimal) {
  var params = {}, value;
  for (var k in prevParams) {
    value = prevParams[k];
    params[k] = typeof value === 'number' ? decimal(value) : value;
  }
  return params;
}
390582
function convertFormatNumber (value, num) {
  // 序数
  if (num === 0) {
    return suji(value, '序数');
  }
  // 0埋め
  if (typeof value === 'number') {
    value = value + '';
    return value.length < num ? ('000000000' + value).slice(-num) : value;
  }
  // 切り捨て
  return num && num < value.length ? value.substring(0, num) : value;
}
1130757
function padNumber(number, length)
    {
        var result = number.toString();

        while (result.length < length)
            result = '0' + result;

        return result;
    }