Skip to content

Instantly share code, notes, and snippets.

@jelmervdl
Created March 15, 2024 13:17
Show Gist options
  • Save jelmervdl/df4f54b400fbdfd82fa6f5243d23e97f to your computer and use it in GitHub Desktop.
Save jelmervdl/df4f54b400fbdfd82fa6f5243d23e97f to your computer and use it in GitHub Desktop.
def expand(expr:str):
if (match := re.search(r"\{(.+?)\}", expr)):
prefix = expr[:match.start()]
for val in match.group(1).split(','):
for suffix in expand(expr[match.end():]):
yield prefix + val + suffix
else:
yield expr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment