Quote:
Originally Posted by lomkiri
Code:
# loop while splitting to break into individual words
for word in textnum.replace("-"," ").split():
# if problem then fail-safe
if word not in numwords:
raise Exception("Illegal word: " + word)
|
NOTE : This function raises an exception if the targeted string is not a number, maybe you want to change this so in that case it returns the input without changes and doesn't raise an exception. If you keep it like this, just be sure that you capture only numbers in your regex.