cpp/src/phonenumbers/phonenumberutil.cc
// Strips the IDD from the start of the number if present. Helper function used
// by MaybeStripInternationalPrefixAndNormalize.
Strips the IDD from the start of the number if present. Helper function used
by MaybeStripInternationalPrefixAndNormalize.
Strips the IDD from the start of the number if present . Helper function used by MaybeStripInternationalPrefixAndNormalize .
bool PhoneNumberUtil::ParsePrefixAsIdd(const RegExp& idd_pattern,
                                       string* number) const {
  DCHECK(number);
  const scoped_ptr<RegExpInput> number_copy(
      reg_exps_->regexp_factory_->CreateInput(*number));
  if (idd_pattern.Consume(number_copy.get())) {
    string extracted_digit;
    if (reg_exps_->capturing_digit_pattern_->PartialMatch(
            number_copy->ToString(), &extracted_digit)) {
      NormalizeDigitsOnly(&extracted_digit);
      if (extracted_digit == "0") {
        return false;
      }
    }
    number->assign(number_copy->ToString());
    return true;
  }
  return false;
}
bool PhoneNumberUtil :: ParsePrefixAsIdd ( const RegExp & idd_pattern , string * number ) const { DCHECK ( number ) ; const scoped_ptr < RegExpInput > number_copy ( reg_exps_ -> regexp_factory_ -> CreateInput ( * number ) ) ; if ( idd_pattern . Consume ( number_copy . get ( ) ) ) { string extracted_digit ; if ( reg_exps_ -> capturing_digit_pattern_ -> PartialMatch ( number_copy -> ToString ( ) , & extracted_digit ) ) { NormalizeDigitsOnly ( & extracted_digit ) ; if ( extracted_digit == " " ) { return false ; } } number -> assign ( number_copy -> ToString ( ) ) ; return true ; } return false ; }
Strips the IDD from the start of the number if present.
Strips the IDD from the start of the number if present .
// First attempt to strip the idd_pattern at the start, if present. We make a // copy so that we can revert to the original string if necessary. // Only strip this if the first digit after the match is not a 0, since // country calling codes cannot begin with 0.