feat: update regex, bug fixes, add tests

This commit is contained in:
Vlasislav Kashin
2025-07-12 23:30:44 +03:00
parent 2fea8f1e20
commit ebe7d236e9
8 changed files with 1866 additions and 898 deletions

View File

@@ -307,13 +307,12 @@ impl PhoneNumberRegExpsAndMappings {
separator_pattern: Regex::new(&format!("[{}]+", VALID_PUNCTUATION)).unwrap(),
extn_patterns_for_matching: create_extn_pattern(false),
extn_pattern: Regex::new(&format!("(?i)(?:{})$", &extn_patterns_for_parsing)).unwrap(),
valid_phone_number_pattern: Regex::new(&format!("(?i){}(?:{})?",
valid_phone_number_pattern: Regex::new(&format!("(?i)(?:{})(?:{})?",
&valid_phone_number,
extn_patterns_for_parsing
)).unwrap(),
valid_alpha_phone_pattern: Regex::new(&format!("(?i)(?:.*?[{}]){{3}}",
VALID_ALPHA
&extn_patterns_for_parsing
)).unwrap(),
// from java
valid_alpha_phone_pattern: Regex::new("(?:.*?[A-Za-z]){3}.*").unwrap(),
// The first_group_capturing_pattern was originally set to $1 but there
// are some countries for which the first group is not used in the
// national pattern (e.g. Argentina) so the $1 group does not match