[Solved] How would i create a regex for the following [closed]


As I understand, the number of groups in a regex pattern is pre-determined. If you need to iterate over all the matches, you could do something like this:

import re

text = """some value {arg1} {arg2} {arg3}
another value {arg1}
idkhere {arg1} {arg2}"""

pattern = re.compile(r"{arg\d}")

for i in re.findall(pattern, text):
    print(i)

2

solved How would i create a regex for the following [closed]