toSingular function

String toSingular(
  1. String plural
)

Return singular form of plural.

Implementation

String toSingular(String plural) {
    final RegExp isAbbr = RegExp(r'[A-Z0-9]$');
    if (isAbbr.hasMatch(plural)) return plural;
    String singular = plural;
    for (final RegExp re in _singularRules.keys) {
        if (re.hasMatch(plural)) {
            singular = plural.replaceFirstMapped(re, _singularRules[re]!);
            break;
        }
    }
    return singular;
}