diff --git a/evennia/utils/tests/test_utils.py b/evennia/utils/tests/test_utils.py index a93ff91f12..b8d23d4829 100644 --- a/evennia/utils/tests/test_utils.py +++ b/evennia/utils/tests/test_utils.py @@ -717,7 +717,7 @@ class TestIntConversions(TestCase): self.assertEqual(20, utils.str2int("twenty")) # multi-place numbers - self.assertEqual(2345, utils.str2int("two thousand, three hundred and thirty-five")) + self.assertEqual(2345, utils.str2int("two thousand, three hundred and forty-five")) # ordinal numbers self.assertEqual(1, utils.str2int("1st")) diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 1830ca9946..6c4b1a6df6 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -2810,6 +2810,9 @@ def str2int(number): if i := _STR2INT_MAP.get(number): # it's a single number, return it return i + + # remove optional "and"s + number = number.replace(" and "," ") # split number words by spaces, hyphens and commas, to accommodate multiple styles numbers = [ word.lower() for word in re.split(r'[-\s\,]',number) if word ]