diff --git a/utils.py b/utils.py new file mode 100644 index 0000000000..c5906ca61e --- /dev/null +++ b/utils.py @@ -0,0 +1,19 @@ +import re + +def extract_numbers(input_string: str) -> list: + """ + Extract all numbers from a given input string. + + This function accepts a string as input and returns a list of found numbers. + It uses regular expressions to match and extract integers, decimals, and + negative numbers from the input string. + + Args: + input_string (str): The string to extract numbers from. + + Returns: + list: A list of extracted numbers. + + """ + pattern = r'-?\d+(\.\d+)?' + return re.findall(pattern, input_string) \ No newline at end of file