import re

from .constants import *


NUMBER_RE = re.compile(r'[-+]?\d*[+p.]?\d+([eE][-+]?\d+)?', re.MULTILINE)
UNSIGNED_NUMBER_RE = re.compile(r'[-+]?\d*[+p.]?\d+([eE][-+]?\d+)?', re.MULTILINE)


def numbers_from_string(any_string: str) -> list[float]:
    matches = []
    for m in NUMBER_RE.finditer(any_string):
        matches.append(float(m.group().replace('p', '.')))
    return matches
