import itertools
import re
from typing import Iterable


def explode(pattern: str) -> Iterable[str]:
    """
    Expand the brace-delimited possibilities in a string.
    """

    seg_choices = (
        seg.strip('{}').split(',') if seg.startswith('{') else [seg]
        for seg in re.split(r'(\{.*?\})', pattern)
    )

    return (''.join(parts) for parts in itertools.product(*seg_choices))