mirror of
https://github.com/xHyroM/dotfiles.git
synced 2024-12-26 14:11:05 +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
|