my problem is when I search a pdf file using python. I search it line by line so suppose I have a line contains:
"this this this %this"
so if we put x = "this this this %this" and I want to count the number of "this" and ignore what proceeds "%" as it is a comment. the code is :
if re.search("%",x):
new_line = x.split()
for g in new_line:
if re.search("%",g):
break
elif g == "this":
counter = counter+1
print (counter)
but what if I have the following:
x = "this this this %this %this" the second percentage ends the comment and I want to skip "this" which is between "%" and count the last one
have any one any Idea to do it ?