feat: update regex, bug fixes, add tests
This commit is contained in:
@@ -50,11 +50,11 @@ pub const VALID_ALPHA_INCL_UPPERCASE: &'static str = "A-Za-z";
|
||||
// prefix. This can be overridden by region-specific preferences.
|
||||
pub const DEFAULT_EXTN_PREFIX: &'static str = " ext. ";
|
||||
|
||||
pub const POSSIBLE_SEPARATORS_BETWEEN_NUMBER_AND_EXT_LABEL: &'static str = "0001";
|
||||
pub const POSSIBLE_SEPARATORS_BETWEEN_NUMBER_AND_EXT_LABEL: &'static str = "[ \u{00A0}\\t,]*";
|
||||
|
||||
// Optional full stop (.) or colon, followed by zero or more
|
||||
// spaces/tabs/commas.
|
||||
pub const POSSIBLE_CHARS_AFTER_EXT_LABEL: &'static str = "[ \u{00A0}\\t,]*";
|
||||
pub const OPTIONAL_EXT_SUFFIX: &'static str = "[:\\.\u{FF0E}]?[ \u{00A0}\\t,-]*";
|
||||
pub const POSSIBLE_CHARS_AFTER_EXT_LABEL: &'static str = "[:\\.\u{FF0E}]?[ \u{00A0}\\t,-]*";
|
||||
pub const OPTIONAL_EXT_SUFFIX: &'static str = "#?";
|
||||
|
||||
pub const NANPA_COUNTRY_CODE: i32 = 1;
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user