onlyAlfabet property

String? onlyAlfabet

Returns only the Latin characters from the String.

Example

String foo = '4*%^55/es4e5523nt1is';
String onlyLatin = foo.onlyLatin; // returns 'esentis'

Implementation

String? get onlyAlfabet {
  if (this == null) return null;
  if (this!.isEmpty) return this;
  final regex = RegExp(r'([^a-zA-Z\s]+)');
  return this!.replaceAll(regex, '');
}