zjowowen's picture
merge files from main branch
0d8bebc
raw
history blame contribute delete
552 Bytes
import re
def check_if_is_number(text: str):
try:
int(text)
return True
except ValueError:
return False
def get_all_numbers_in_a_sentence(text: str):
return [int(i) for i in re.findall(r'[-+]?\d+', text)]
def get_all_numbers_in_a_sentence_with_comma(text: str):
#remove comma in numbers
text = text.replace(',', '')
return [int(i) for i in re.findall(r'[-+]?\d+', text)]
def get_all_numbers(text: str):
return get_all_numbers_in_a_sentence(text) + get_all_numbers_in_a_sentence_with_comma(text)