Helper method to get the national-number part of a number, formatted without any national
    prefix, and return it as a set of digit blocks that would be formatted together following
    standard formatting rules.
331597
def _get_national_number_groups_without_pattern(numobj):
    """"""
    # This will be in the format +CC-DG1-DG2-DGX;ext=EXT where DG1..DGX represents groups of
    # digits.
    rfc3966_format = format_number(numobj, PhoneNumberFormat.RFC3966)
    # We remove the extension part from the formatted string before splitting
    # it into different groups.
    end_index = rfc3966_format.find(U_SEMICOLON)
    if end_index < 0:
        end_index = len(rfc3966_format)

    # The country-code will have a '-' following it.
    start_index = rfc3966_format.find(U_DASH) + 1
    return rfc3966_format[start_index:end_index].split(U_DASH)
151280
private static String convertLessThanOneThousand(int number) {
		String soFar;

		if (number % 100 < 20) {
			soFar = numNames[number % 100];
			number /= 100;
		} else {
			soFar = numNames[number % 10];
			number /= 10;

			soFar = tensNames[number % 10] + soFar;
			number /= 10;
		}
		if (number == 0) {
			return soFar;
		}
		return numNames[number] + " Hundred" + soFar;
	}
609860
def partial_split number
        cc = ''
        1.upto(3) do |i|
          cc << number.slice!(0..0)
          country = countries[i][cc]
          return [country, cc, number] if country
        end
        # This line is never reached as CCs are in prefix code.
      end
470692
def vanity? number
      country, _, national = partial_split number
      country.vanity? national
    end
1284655
def split national_number
      _, trunk, ndc, *rest = internal_split national_number
      [trunk, ndc, *rest]
    end
650754
def _expand_formatting_rule(rule, national_prefix):
    
    if rule is None:
        return None
    if national_prefix is None:
        national_prefix = u("")
    rule = re.sub(u(r"\$NP"), national_prefix, rule)
    rule = re.sub(u(r"\$FG"), u("$1"), rule)
    return rule
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)
147399
function(n){

        // Examine international prefix
        if(n.substr(0,2) === '61'){
            return n.length === 11;
        }

        // Examine international prefix
        if(n.substr(0,4) === '0061'){
            return n.length === 13;
        }

        // Examine number of digits
        return n.length === 10;
    }
828830
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;
  }
641030
def local_number
      return national unless possible?
      format_match, format_string = formatting_data

      if format_string =~ /^.*[0-9]+.*\$1/ && format_match
        format_string.gsub(/^.*\$2/, '$2')
          .gsub(/\$\d/) { |el| format_match[el[1].to_i] }
      else
        national
      end
    end
370153
def numeric_part(s):
    

    m = re_numeric_part.match(s)
    if m:
        return int(m.group(1))
    return None
367012
public String getDenominatorPartAfter(final int digit) {
        
        final int length = denominatorPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        return denominatorPart.substring(0, (length - digit + 1));
    }
671159
def read_digits(ctx, text):
    
    def chunk(value, chunk_size):
        return [value[i: i + chunk_size] for i in range(0, len(value), chunk_size)]

    text = conversions.to_string(text, ctx).strip()
    if not text:
        return ''

    # trim off the plus for phone numbers
    if text[0] == '+':
        text = text[1:]

    length = len(text)

    # ssn
    if length == 9:
        result = ' '.join(text[:3])
        result += ' , ' + ' '.join(text[3:5])
        result += ' , ' + ' '.join(text[5:])
        return result

    # triplets, most international phone numbers
    if length % 3 == 0 and length > 3:
        chunks = chunk(text, 3)
        return ' '.join(','.join(chunks))

    # quads, credit cards
    if length % 4 == 0:
        chunks = chunk(text, 4)
        return ' '.join(','.join(chunks))

    # otherwise, just put a comma between each number
    return ','.join(text)
992706
private function removeNationalPrefixFromNationalNumber()
    {
        $startOfNationalNumber = 0;
        if ($this->isNanpaNumberWithNationalPrefix()) {
            $startOfNationalNumber = 1;
            $this->prefixBeforeNationalNumber .= '1' . self::$seperatorBeforeNationalNumber;
            $this->isCompleteNumber = true;
        } elseif ($this->currentMetadata->hasNationalPrefixForParsing()) {
            $m = new Matcher($this->currentMetadata->getNationalPrefixForParsing(), $this->nationalNumber);
            // Since some national prefix patterns are entirely optional, check that a national prefix
            // could actually be extracted.
            if ($m->lookingAt() && $m->end() > 0) {
                // When the national prefix is detected, we use international formatting rules instead of
                // national ones, because national formatting rules could contain local formatting rules
                // for numbers entered without area code.
                $this->isCompleteNumber = true;
                $startOfNationalNumber = $m->end();
                $this->prefixBeforeNationalNumber .= mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
            }
        }
        $nationalPrefix = mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
        $this->nationalNumber = mb_substr($this->nationalNumber, $startOfNationalNumber);
        return $nationalPrefix;
    }
345905
public static NumberFormat makeNumberFormat(int digits) {
    // Prefer predefined number formats where applicable.
    // TODO: cache others, too?
    switch(digits){
    case 0:
      return NF0;
    case 2:
      return NF2;
    case 3:
      return NF3;
    case 4:
      return NF4;
    case 6:
      return NF6;
    case 8:
      return NF8;
    }
    final NumberFormat nf = NumberFormat.getInstance(Locale.US);
    nf.setMaximumFractionDigits(digits);
    nf.setMinimumFractionDigits(digits);
    nf.setGroupingUsed(false);
    return nf;
  }
1046883
def _clear(self):
        """"""
        self._current_output = U_EMPTY_STRING
        self._accrued_input = U_EMPTY_STRING
        self._accrued_input_without_formatting = U_EMPTY_STRING
        self._formatting_template = U_EMPTY_STRING
        self._last_match_position = 0

        # The pattern from number_format that is currently used to create
        # formatting_template.
        self._current_formatting_pattern = U_EMPTY_STRING
        # This contains anything that has been entered so far preceding the
        # national significant number, and it is formatted (e.g. with space
        # inserted). For example, this can contain IDD, country code, and/or
        # NDD, etc.
        self._prefix_before_national_number = U_EMPTY_STRING
        self._should_add_space_after_national_prefix = False
        # This contains the national prefix that has been extracted. It
        # contains only digits without formatting.
        self._extracted_national_prefix = U_EMPTY_STRING
        self._national_number = U_EMPTY_STRING
        # This indicates whether AsYouTypeFormatter is currently doing the
        # formatting.
        self._able_to_format = True
        # Set to true when users enter their own
        # formatting. AsYouTypeFormatter will do no formatting at all when
        # this is set to True.
        self._input_has_formatting = False
        # The position of a digit upon which input_digit(remember_position=True) is
        # most recently invoked, as found in accrued_input_without_formatting.
        self._position_to_remember = 0
        # The position of a digit upon which input_digit(remember_position=True) is
        # most recently invoked, as found in the original sequence of
        # characters the user entered.
        self._original_position = 0
        # This is set to true when we know the user is entering a full
        # national significant number, since we have either detected a
        # national prefix or an international dialing prefix. When this is
        # true, we will no longer use local number formatting patterns.
        self._is_complete_number = False
        self._is_expecting_country_calling_code = False
        self._possible_formats = []
644056
function get($countryCode = false, $separator = '')
    {
        if ($countryCode == false) {
            $formattedNumber = '0' . $this->msisdn;

            if ( ! empty($separator)) {
                $formattedNumber = substr_replace($formattedNumber, $separator, 4, 0);
                $formattedNumber = substr_replace($formattedNumber, $separator, 8, 0);
            }

            return $formattedNumber;
        } else {
            $formattedNumber = $this->countryPrefix . $this->msisdn;

            if ( ! empty($separator)) {
                $formattedNumber = substr_replace($formattedNumber, $separator, strlen($this->countryPrefix), 0);
                $formattedNumber = substr_replace($formattedNumber, $separator, 7, 0);
                $formattedNumber = substr_replace($formattedNumber, $separator, 11, 0);
            }

            return $formattedNumber;
        }
    }