mirror of
https://github.com/xHyroM/dotfiles.git
synced 2024-11-09 17:08:06 +01:00
15 lines
392 B
Python
15 lines
392 B
Python
import re
|
|
|
|
def expand(pattern: str) -> list[str]:
|
|
match = re.search(r'\{([^{}]*)\}', pattern)
|
|
if not match:
|
|
return [pattern]
|
|
|
|
pre, post = pattern[:match.start()], pattern[match.end():]
|
|
options = match.group(1).split(',')
|
|
|
|
expanded_patterns = []
|
|
for option in options:
|
|
expanded_patterns.extend(expand(pre + option + post))
|
|
|
|
return expanded_patterns
|