import string


def get_number(s, cast=int):
    """
    Try to get a number out of a string, and cast it.
    """

    d = "".join(x for x in str(s) if x in string.digits)
    return cast(d) if d else s