parse static method

int parse(
  1. String word
)

Attempts to parse a number from a literal number or int in the form of a String.

Implementation

static int parse(String word) {
  word = word.replaceAll(" ", "").toLowerCase().trim();
  int result = 0;
  if (word.isEmpty) {
    return result;
  }
  final parsedValue = int.tryParse(word);
  if (parsedValue != null) {
    return parsedValue;
  }
  if (WordToIntegerUtils._wordToDigit.containsKey(word)) {
    return _wordToDigit[word]!;
  }

  return result;
}