Fixes issues #7, #10, #13. Prefix matching related (java equivalent == LookingAt() ) #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In (at least) these 2 places, a regular match/FindIndex was used instead of enforcing matching from the start of the string, like LookingAt() does in the Java implementation.
So for maybeStripNationalPrefixAndCarrierCode, country prefixes (e.g. "0") were matched and truncated at any place in the number, and most cases were saved by the fact that the resulting number would be of an invalid size. But in some situations (like #13), the number legal size would be flexible enough to allow the incorrectly truncated number to go through.
Same thing for parsePrefixAsIdd. Furthermore, line 2553 find[1] was incorrect. You cannot make the assumption that len(find) > 1, so index 1 might be out of range. Java implem used groups(1) because groups(0) has a special meaning (== whole string), but it in fact used the first match, corresponding to find[0] here.