removeLetters property
String?
get
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.isBlank) {
return this;
}
// ignore: unnecessary_raw_strings
var regex = RegExp(r'([a-zA-Z]+)');
return this.replaceAll(regex, '');
}