I have a string in Python like the following:
str = "Surname:.......1 of 10 Surname:........2 of 10 Surname.........3 of 10............."
I want to take every substring of the form:
"Surname:.......<number> of 10"
and edit it.
How could I take the n (above is 10) substrings that starts and end with the same form? I have tried the following :
str = 'Surname:mike 1 of 3 Surname:uknown of 3 Surname:little 3 of 3'
x = re.findall("Surname:.*[0-9]*\s*of", str)
print(x)
but the result is :
['Surname:mike 1 of 3 Surname:uknown of 3 Surname:little 3 of 3']
and I want something like this :
['Surname:mike 1 of 3','Surname:unkown 2 of 3','Surname:little 3 of 3']
Of course I think there is a solution to iterate through the string but firstly I want to see if there is another solution with less code.