onlyNumbers property
String?
onlyNumbers
Returns only the numbers from the String.
Example
String foo = '4*%^55/es4e5523nt1is';
String onyNumbers = foo.onlyNumbers; // returns '455455231'
Implementation
String? get onlyNumbers {
if (this == null) return null;
if (this!.isEmpty) return this;
final regex = RegExp('([^0-9]+)');
return this!.replaceAll(regex, '');
}