removeOrdinalSuffix function

String removeOrdinalSuffix(
  1. String word
)

Removes ordinal suffixes to numbers

Implementation

String removeOrdinalSuffix(String word) {
  if (word.isEmpty) return word;

  word = word
      .replaceAll(RegExp(ordinalSuffix, caseSensitive: false), '')
      .replaceAll(RegExp(ordinalSuffixSeparate, caseSensitive: false), '');
  if (word.endsWith(thirdFa)) {
    word = word.substring(0, word.length - 3) + threeFa;
  } else if (word.endsWith(ordinalSuffixSingle)) {
    word = word.substring(0, word.length - 1);
  }

  return word;
}