def get(item, default=None):
    """Get item from value (value[item]).

    If the item is not found, return the default.

    Handles XML elements, regex matches and anything that has __getitem__.
    """

    def getter(value):
        if ET.iselement(value):
            value = value.attrib

        try:
            # Use .group() if this is a regex match object
            if _is_re_match(value):
                return value.group(item)
            else:
                return value[item]
        except (KeyError, IndexError):
            return default
        except (TypeError, AttributeError) as err:
            raise ValueError(err)

    return transform(getter)
Get item from value (value[item]).

    If the item is not found, return the default.

    Handles XML elements, regex matches and anything that has __getitem__.