[Solved] How to extract data from formatted string using python?


You should certainly read more on regex. A first hint is that when you want to capture a pattern you need to enclose it in parentheses. e.g. (\d+). For this example though, the code you need is:

match = re.match(r'C(\d+)([F|G])(\d+)\.PNG', s)

first_id = match.group(1)
fg_class = match.group(2)
second_id = match.group(3)

1

solved How to extract data from formatted string using python?