|
1 |
| -class Constants { |
2 |
| - /// The minimum and maximum length of the country calling code. |
3 |
| - static const int minLengthCountryCallingCode = 1; |
4 |
| - static const int maxLengthCountryCallingCode = 3; |
5 |
| - |
6 |
| - /// The minimum and maximum length of the national significant number. |
7 |
| - /// lib phone number uses 2 but ITU says it's 3 |
8 |
| - static const int minLengthNsn = 3; |
9 |
| - |
10 |
| - /// The ITU says the maximum length should be 15, but we have found longer numbers in Germany. |
11 |
| - static const int maxLengthNsn = 17; |
12 |
| - |
13 |
| - /// New Zealand can have 5 digits |
14 |
| - static const int minLengthCountryPlusNsn = 5; |
15 |
| - |
16 |
| - /// accepted punctuation within a phone number |
17 |
| - static const String _punctuation = r' ()\[\]\-\.\/\\'; |
18 |
| - static const String _plus = r'++'; |
19 |
| - |
20 |
| - /// Westhen and easthern arabic numerals |
21 |
| - static const String _digits = r'0-90-9٠-٩۰-۹'; |
22 |
| - |
23 |
| - /// Regex to find possible phone number candidates in a string. |
24 |
| - /// |
25 |
| - /// This regex tries to match all phone numbers. It doesn't match special |
26 |
| - /// numbers like the 100. |
27 |
| - /// |
28 |
| - /// The regex must start by either a + or a digit, then be followed by at least 6 digits. |
29 |
| - /// The digits are formed of westhern and easthern numerals. |
30 |
| - /// There can also be punctuation between the digts. |
31 |
| - static final String possiblePhoneNumber = |
32 |
| - '[$_plus$_digits](?:[$_punctuation]{0,3}[$_digits]){6,}'; |
33 |
| - |
34 |
| - /// Matches strings that look like dates using "/" as a separator. Examples: 3/10/2011, 31/10/96 or |
35 |
| - /// 08/31/95. |
36 |
| - static final Pattern slashSeparatedDates = |
37 |
| - r'(?:(?:[0-3]?\\d/[01]?\\d)|(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}'; |
38 |
| - // Replace Easthern to Westhern arabic numbers https://en.wikipedia.org/wiki/Eastern_Arabic_numerals |
39 |
| - static Map<String, String> allNormalizationMappings = { |
40 |
| - '+': '+', |
41 |
| - '+': '+', |
42 |
| - '0': '0', |
43 |
| - '1': '1', |
44 |
| - '2': '2', |
45 |
| - '3': '3', |
46 |
| - '4': '4', |
47 |
| - '5': '5', |
48 |
| - '6': '6', |
49 |
| - '7': '7', |
50 |
| - '8': '8', |
51 |
| - '9': '9', |
52 |
| - '٠': '0', |
53 |
| - '١': '1', |
54 |
| - '٢': '2', |
55 |
| - '٣': '3', |
56 |
| - '٤': '4', |
57 |
| - '٥': '5', |
58 |
| - '٦': '6', |
59 |
| - '٧': '7', |
60 |
| - '٨': '8', |
61 |
| - '٩': '9', |
62 |
| - '۰': '0', |
63 |
| - '۱': '1', |
64 |
| - '۲': '2', |
65 |
| - '۳': '3', |
66 |
| - '۴': '4', |
67 |
| - '۵': '5', |
68 |
| - '۶': '6', |
69 |
| - '۷': '7', |
70 |
| - '۸': '8', |
71 |
| - '۹': '9', |
72 |
| - }; |
73 |
| -} |
| 1 | +class Constants { |
| 2 | + /// The minimum and maximum length of the country calling code. |
| 3 | + static const int minLengthCountryCallingCode = 1; |
| 4 | + static const int maxLengthCountryCallingCode = 3; |
| 5 | + |
| 6 | + /// The minimum and maximum length of the national significant number. |
| 7 | + /// lib phone number uses 2 but ITU says it's 3 |
| 8 | + static const int minLengthNsn = 3; |
| 9 | + |
| 10 | + /// The ITU says the maximum length should be 15, but we have found longer numbers in Germany. |
| 11 | + static const int maxLengthNsn = 17; |
| 12 | + |
| 13 | + /// New Zealand can have 5 digits |
| 14 | + static const int minLengthCountryPlusNsn = 5; |
| 15 | + |
| 16 | + /// accepted punctuation within a phone number |
| 17 | + static const String _punctuation = r' ()\[\]\-\.\/\\'; |
| 18 | + static const String _plus = r'++'; |
| 19 | + |
| 20 | + /// Westhen and easthern arabic numerals |
| 21 | + static const String _digits = r'0-90-9٠-٩۰-۹'; |
| 22 | + |
| 23 | + /// Regex to find possible phone number candidates in a string. |
| 24 | + /// |
| 25 | + /// This regex tries to match all phone numbers. It doesn't match special |
| 26 | + /// numbers like the 100. |
| 27 | + /// |
| 28 | + /// The regex must start by either a + or a digit, then be followed by at least 6 digits. |
| 29 | + /// The digits are formed of westhern and easthern numerals. |
| 30 | + /// There can also be punctuation between the digts. |
| 31 | + static final String possiblePhoneNumber = |
| 32 | + '[$_plus$_digits](?:[$_punctuation]{0,3}[$_digits]){6,}'; |
| 33 | + |
| 34 | + /// Matches strings that look like dates using "/" as a separator. Examples: 3/10/2011, 31/10/96 or |
| 35 | + /// 08/31/95. |
| 36 | + static final Pattern slashSeparatedDates = |
| 37 | + r'(?:(?:[0-3]?\\d/[01]?\\d)|(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}'; |
| 38 | + // Replace Easthern to Westhern arabic numbers https://en.wikipedia.org/wiki/Eastern_Arabic_numerals |
| 39 | + static Map<String, String> allNormalizationMappings = { |
| 40 | + '+': '+', |
| 41 | + '+': '+', |
| 42 | + '0': '0', |
| 43 | + '1': '1', |
| 44 | + '2': '2', |
| 45 | + '3': '3', |
| 46 | + '4': '4', |
| 47 | + '5': '5', |
| 48 | + '6': '6', |
| 49 | + '7': '7', |
| 50 | + '8': '8', |
| 51 | + '9': '9', |
| 52 | + '٠': '0', |
| 53 | + '١': '1', |
| 54 | + '٢': '2', |
| 55 | + '٣': '3', |
| 56 | + '٤': '4', |
| 57 | + '٥': '5', |
| 58 | + '٦': '6', |
| 59 | + '٧': '7', |
| 60 | + '٨': '8', |
| 61 | + '٩': '9', |
| 62 | + '۰': '0', |
| 63 | + '۱': '1', |
| 64 | + '۲': '2', |
| 65 | + '۳': '3', |
| 66 | + '۴': '4', |
| 67 | + '۵': '5', |
| 68 | + '۶': '6', |
| 69 | + '۷': '7', |
| 70 | + '۸': '8', |
| 71 | + '۹': '9', |
| 72 | + }; |
| 73 | +} |
0 commit comments