<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def re_flags(flags, custom=ReFlags):
 """Parse regexp flag string. Parameters flags: `str` Flag string. custom: `IntEnum`, optional Custom flag enum (default: None). Returns ------- (`int`, `int`) (flags for `re.compile`, custom flags) Raises ------ ValueError """

    re_, custom_ = 0, 0
    for flag in flags.upper():
        try:
            re_ |= getattr(re, flag)
        except AttributeError:
            if custom is not None:
                try:
                    custom_ |= getattr(custom, flag)
                except AttributeError:
                    raise ValueError('Invalid custom flag "%s"' % flag)
            else:
                raise ValueError('Invalid regexp flag "%s"' % flag)
    return re_, custom_