code: def re_flags(flags, custom=ReFlags):
      
      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_
docs: 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