import re


def _code_from_varname(varname):
    """Returns a code from a varname.

    Used typically for varnames create by a `cdo -f nc copy` command
    on IEG files.
    """
    if "var" in varname:

        return int(re.findall("[0-9]+", varname)[0])
    else:
        return None