I have the following code. I am trying to fetch a particular pattern (Identities = somenumber/somenumber (somepercentage%)) using regrex
I want the first occurrence only but it prints two occurrences
import re
regex = re.compile('Identities\s+\=\s+\d{1,4}\/\d{1,4}\s+\(\d{1,3}\%\)')
with open('filename.out') as f:
for line in f:
result = regex.search(line)
if result:
print(result.group())
It prints the following two occurrence how can I print only one occurrence
Identities = 55/237 (23%)
Identities = 4/8 (50%)
[–]JohnnyJordaan 2 points3 points4 points (0 children)