matchingCharacterDescription property

String get matchingCharacterDescription

Returns a human-readable description of the matching character.

This formats the character with additional context:

  • For letters: Indicates case (upper/lower) and shows uppercase version
  • For digits: Adds "Digit" prefix and special handling for zero
  • For other characters: Simply returns the character in quotes

Implementation

String get matchingCharacterDescription {
  String description = '"$matchingCharacter"';

  if (isLetter(matchingCharacter)) {
    if (isUpperCase(matchingCharacter)) {
      description = 'Upper case';
    } else {
      description = 'Lower case';
    }
    description += ' "${matchingCharacter.toUpperCase()}"';
  }

  if (isDigit(matchingCharacter)) {
    description =
        'Digit "$matchingCharacter"${matchingCharacter == '0' ? ' Zero' : ''}';
  }
  return description;
}