I have the following strings:
4563_1_some_data
The general pattern is
r'\d{1,5}_[1-4]_some_data
Note, that numbers before first underscore may be the same for different some_data
So the question is: how to get all possible variants of replacement using regex?
Desired output:
[4563_1_some_data, 4563_2_some_data, 4563_3_some_data, 4563_4_some_data]
My attempt:
[re.sub(r'_\d_', r'_[1-4]_', row).group() for row in data]
But it has result:
4563_[1-4]_some_data
Seems like ordinary replacement. How should I activate pattern replacement and get the list?