@@ -160,6 +160,46 @@ RegExp _bic = RegExp(r'^[A-Z]{4}[A-Z]{2}\w{2}(\w{3})?$');
160
160
RegExp _time = RegExp (
161
161
r'^(?:[01]\d|2[0-3]):[0-5]\d$|^(?:0?[1-9]|1[0-2]):[0-5]\d\s?(?:[AaPp][Mm])$' );
162
162
163
+ /// {@template upper_case_template}
164
+ /// This regex matches any character that is not an uppercase letter (A-Z) or Ñ.
165
+ ///
166
+ /// - It includes special characters, digits, and lowercase letters.
167
+ /// - It can be used to find non-uppercase characters.
168
+ ///
169
+ /// Examples: a, 1, @
170
+ /// {@endtemplate}
171
+ RegExp _upperCase = RegExp (r'[^A-ZÑ]' );
172
+
173
+ /// {@template lower_case_template}
174
+ /// This regex matches any character that is not a lowercase letter (a-z) or ñ.
175
+ ///
176
+ /// - It includes special characters, digits, and uppercase letters.
177
+ /// - It can be used to find non-lowercase characters.
178
+ ///
179
+ /// Examples: A, 1, @
180
+ /// {@endtemplate}
181
+ RegExp _lowerCase = RegExp (r'[^a-zñ]' );
182
+
183
+ /// {@template number_template}
184
+ /// This regex matches any character that is not a digit (0-9).
185
+ ///
186
+ /// - It includes special characters, letters, and other non-numeric characters.
187
+ /// - It can be used to find non-digit characters.
188
+ ///
189
+ /// Examples: a, A, @
190
+ /// {@endtemplate}
191
+ RegExp _number = RegExp (r'[^0-9]' );
192
+
193
+ /// {@template special_char_template}
194
+ /// This regex matches any character that is not a letter (A-Z, a-z) or a digit (0-9).
195
+ ///
196
+ /// - It includes special characters and symbols.
197
+ /// - It can be used to find non-alphanumeric characters.
198
+ ///
199
+ /// Examples: @, #, %
200
+ /// {@endtemplate}
201
+ RegExp _specialChar = RegExp (r'[A-Za-z0-9]' );
202
+
163
203
int _maxUrlLength = 2083 ;
164
204
165
205
/// check if the string [str] is an email
@@ -471,19 +511,19 @@ bool isColorCode(String value,
471
511
}
472
512
473
513
int uppercaseCharLength (String value) {
474
- return value.replaceAll (RegExp ( r'[^A-ZÑ]' ) , '' ).length;
514
+ return value.replaceAll (_upperCase , '' ).length;
475
515
}
476
516
477
517
int lowercaseCharLength (String value) {
478
- return value.replaceAll (RegExp ( r'[^a-zñ]' ) , '' ).length;
518
+ return value.replaceAll (_lowerCase , '' ).length;
479
519
}
480
520
481
521
int numberCharLength (String value) {
482
- return value.replaceAll (RegExp ( r'[^0-9]' ) , '' ).length;
522
+ return value.replaceAll (_number , '' ).length;
483
523
}
484
524
485
525
int specialCharLength (String value) {
486
- return value.replaceAll (RegExp ( r'[A-Za-z0-9]' ) , '' ).length;
526
+ return value.replaceAll (_specialChar , '' ).length;
487
527
}
488
528
489
529
bool isAlphabetical (String value) {
0 commit comments