import re def get_3nums(text): '''Return a list of all exactly 3-digit numbers in text.''' return re.findall(r'\b\d{3}\b', text) def is_int(text): '''Return whether text is a string representation of an integer.''' return re.search(r'^-?\d+$', text) != None def is_float(text): '''Return whether text is a string representation of a float.''' return re.search(r'^-?\d+\.\d+$', text) != None def modifier_demo(): '''A demonstration of the quantity modifiers.''' text = 'cabbbb abe draw' print(text) print('+', re.findall(r'ab+', text)) print('*', re.findall(r'ab*', text)) print('?', re.findall(r'ab?', text))