Skip to content

Commit

Permalink
Merge pull request #150 from hemachandran-kalaimani/issue-147-fix-get…
Browse files Browse the repository at this point in the history
…LengthOfNationalDestinationCode

Fix regex matching in GetLengthOfNationalDestinationCode
  • Loading branch information
rowanseymour authored Nov 17, 2023
2 parents 85be252 + 1ac248f commit 6096ac3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions phonenumbers.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func GetLengthOfNationalDestinationCode(number *PhoneNumber) int {
}

nationalSignificantNumber := Format(copiedProto, INTERNATIONAL)
numberGroups := DIGITS_PATTERN.FindAllString(nationalSignificantNumber, -1)
numberGroups := NON_DIGITS_PATTERN.Split(nationalSignificantNumber, -1)

// The pattern will start with "+COUNTRY_CODE " so the first group
// will always be the empty string (before the + symbol) and the
Expand All @@ -959,7 +959,7 @@ func GetLengthOfNationalDestinationCode(number *PhoneNumber) int {
return len(numberGroups[1]) + len(numberGroups[2])
}
}
return len(numberGroups[1])
return len(numberGroups[2])
}

// Returns the mobile token for the provided country calling code if it
Expand Down

0 comments on commit 6096ac3

Please sign in to comment.