i have to find and extract from a text a series of line of these type:
- featureSetCombination : 1
- featureSetCombination : 2
- ...
- featureSetCombination : 10
- featureSetCombination : 11
- ...
- featureSetCombination : 100
Since only the final number changes in the phrases to search for, my idea is to build the phrase progressively by increasing the final value in this way.
with open('temp.txt') as file:
for line in file:
num = 1
str = 'featureSetCombination : ' + str(num)
if xxx
action
num += 1
The problem is that I have to search for exactly the string with the number; for example the search for "featureSetCombination : 1" would also produce results with "featureSetCombination : 10" or "featureSetCombination : 11" which for what I have to do is not good. I also thought about adding a space after the number to my string, but the idea is not feasible. The only way is by searching for my string exactly. Can you help me? Many thanks :)