dist/upptalk.js
function ParseNumber(number, defaultRegion) {
    var ret;

    // Remove formating characters and whitespace.
    number = PhoneNumberNormalizer.Normalize(number);

    // If there is no defaultRegion, we can't parse international access codes.
    if (!defaultRegion && number[0] !== '+')
      return null;

    // Detect and strip leading '+'.
    if (number[0] === '+')
      return ParseInternationalNumber(number.replace(LEADING_PLUS_CHARS_PATTERN, ""));

    // Lookup the meta data for the given region.
    var md = FindMetaDataForRegion(defaultRegion.toUpperCase());

    // See if the number starts with an international prefix, and if the
    // number resulting from stripping the code is valid, then remove the
    // prefix and flag the number as international.
    if (md.internationalPrefix.test(number)) {
      var possibleNumber = number.replace(md.internationalPrefix, "");
      ret = ParseInternationalNumber(possibleNumber)
      if (ret)
        return ret;
    }

    // This is not an international number. See if its a national one for
    // the current region. National numbers can start with the national
    // prefix, or without.
    if (md.nationalPrefixForParsing) {
      // Some regions have specific national prefix parse rules. Apply those.
      var withoutPrefix = number.replace(md.nationalPrefixForParsing,
                                         md.nationalPrefixTransformRule || '');
      ret = ParseNationalNumber(withoutPrefix, md)
      if (ret)
        return ret;
    } else {
      // If there is no specific national prefix rule, just strip off the
      // national prefix from the beginning of the number (if there is one).
      var nationalPrefix = md.nationalPrefix;
      if (nationalPrefix && number.indexOf(nationalPrefix) == 0 &&
          (ret = ParseNationalNumber(number.substr(nationalPrefix.length), md))) {
        return ret;
      }
    }
    ret = ParseNationalNumber(number, md)
    if (ret)
      return ret;

    // Now lets see if maybe its an international number after all, but
    // without '+' or the international prefix.
    ret = ParseInternationalNumber(number)
    if (ret)
      return ret;

    // If the number matches the possible numbers of the current region,
    // return it as a possible number.
    if (md.possiblePattern.test(number))
      return new NationalNumber(md, number);

    // We couldn't parse the number at all.
    return null;
  }
function ParseNumber(number, defaultRegion) {
    var ret;

    // Remove formating characters and whitespace.
    number = PhoneNumberNormalizer.Normalize(number);

    // If there is no defaultRegion, we can't parse international access codes.
    if (!defaultRegion && number[0] !== '+')
      return null;

    // Detect and strip leading '+'.
    if (number[0] === '+')
      return ParseInternationalNumber(number.replace(LEADING_PLUS_CHARS_PATTERN, ""));

    // Lookup the meta data for the given region.
    var md = FindMetaDataForRegion(defaultRegion.toUpperCase());

    // See if the number starts with an international prefix, and if the
    // number resulting from stripping the code is valid, then remove the
    // prefix and flag the number as international.
    if (md.internationalPrefix.test(number)) {
      var possibleNumber = number.replace(md.internationalPrefix, "");
      ret = ParseInternationalNumber(possibleNumber)
      if (ret)
        return ret;
    }

    // This is not an international number. See if its a national one for
    // the current region. National numbers can start with the national
    // prefix, or without.
    if (md.nationalPrefixForParsing) {
      // Some regions have specific national prefix parse rules. Apply those.
      var withoutPrefix = number.replace(md.nationalPrefixForParsing,
                                         md.nationalPrefixTransformRule || '');
      ret = ParseNationalNumber(withoutPrefix, md)
      if (ret)
        return ret;
    } else {
      // If there is no specific national prefix rule, just strip off the
      // national prefix from the beginning of the number (if there is one).
      var nationalPrefix = md.nationalPrefix;
      if (nationalPrefix && number.indexOf(nationalPrefix) == 0 &&
          (ret = ParseNationalNumber(number.substr(nationalPrefix.length), md))) {
        return ret;
      }
    }
    ret = ParseNationalNumber(number, md)
    if (ret)
      return ret;

    // Now lets see if maybe its an international number after all, but
    // without '+' or the international prefix.
    ret = ParseInternationalNumber(number)
    if (ret)
      return ret;

    // If the number matches the possible numbers of the current region,
    // return it as a possible number.
    if (md.possiblePattern.test(number))
      return new NationalNumber(md, number);

    // We couldn't parse the number at all.
    return null;
  }
function ParseNumber ( number , defaultRegion ) { var ret ; // Remove formating characters and whitespace. number = PhoneNumberNormalizer . Normalize ( number ) ; // If there is no defaultRegion, we can't parse international access codes. if ( ! defaultRegion && number [ 0 ] !== '+' ) return null ; // Detect and strip leading '+'. if ( number [ 0 ] === '+' ) return ParseInternationalNumber ( number . replace ( LEADING_PLUS_CHARS_PATTERN , "" ) ) ; // Lookup the meta data for the given region. var md = FindMetaDataForRegion ( defaultRegion . toUpperCase ( ) ) ; // See if the number starts with an international prefix, and if the // number resulting from stripping the code is valid, then remove the // prefix and flag the number as international. if ( md . internationalPrefix . test ( number ) ) { var possibleNumber = number . replace ( md . internationalPrefix , "" ) ; ret = ParseInternationalNumber ( possibleNumber ) if ( ret ) return ret ; } // This is not an international number. See if its a national one for // the current region. National numbers can start with the national // prefix, or without. if ( md . nationalPrefixForParsing ) { // Some regions have specific national prefix parse rules. Apply those. var withoutPrefix = number . replace ( md . nationalPrefixForParsing , md . nationalPrefixTransformRule || '' ) ; ret = ParseNationalNumber ( withoutPrefix , md ) if ( ret ) return ret ; } else { // If there is no specific national prefix rule, just strip off the // national prefix from the beginning of the number (if there is one). var nationalPrefix = md . nationalPrefix ; if ( nationalPrefix && number . indexOf ( nationalPrefix ) == 0 && ( ret = ParseNationalNumber ( number . substr ( nationalPrefix . length ) , md ) ) ) { return ret ; } } ret = ParseNationalNumber ( number , md ) if ( ret ) return ret ; // Now lets see if maybe its an international number after all, but // without '+' or the international prefix. ret = ParseInternationalNumber ( number ) if ( ret ) return ret ; // If the number matches the possible numbers of the current region, // return it as a possible number. if ( md . possiblePattern . test ( number ) ) return new NationalNumber ( md , number ) ; // We couldn't parse the number at all. return null ; }
Parse a number and transform it into the national format, removing any international dial prefixes and country codes.
Parse a number and transform it into the national format removing any international dial prefixes and country codes .