numericOnly method

String? numericOnly()

Returns only the numeric characters from the string.

Example:

"a1b2c3".numericOnly(); // "123"

Returns null if string is null.

Implementation

String? numericOnly() {
  if (this == null) return null;
  return this!.replaceAll(RegExp(r'[^0-9]'), '');
}