import re


def cast_to_int(cast):
    """given a string naming a cast, remove non-alpha characters and parse as int"""
    try:
        return int(re.sub('^[^0-9]+','',cast))
    except:
        raise ValueError('cannot interpret cast {} as an integer'.format(cast))