removeLetters property
String?
removeLetters
Removes only the letters from the String.
Example 1
String foo = 'es4e5523nt1is';
String noLetters = foo.removeLetters; // returns '455231'
Example 2
String foo = '1244e*s*4e*5523n*t*1i*s';
String noLetters = foo.removeLetters; // returns '1244**4*5523**1*'
Implementation
String? get removeLetters {
if (this == null) {
return null;
}
if (this!.isEmpty) {
return this;
}
// ignore: unnecessary_raw_strings
final regex = RegExp(r'([a-zA-Z]+)');
return this!.replaceAll(regex, '');
}