lettersOnly method

  1. @useResult
String lettersOnly()

Extracts only ASCII letter characters (A-Z, a-z) from this string.

Note: This is ASCII-only; Unicode letters like 'é' or '你' are removed.

Example:

'Hello123World!'.lettersOnly(); // 'HelloWorld'
'abc-def'.lettersOnly(); // 'abcdef'
'123'.lettersOnly(); // ''
'café'.lettersOnly(); // 'caf' (é removed)

Implementation

@useResult
String lettersOnly() {
  if (isEmpty) {
    return '';
  }

  return replaceAll(_alphaOnlyRegex, '');
}