import re
sum=0
file = open("pro.txt").readlines()
for lines in file:
word= len(re.findall('(^|[^\w\-])able#1(?=([^\w\-]|$))', lines))
if word>0:
sum=sum+1
print sum
I am counting number of words in text file , but my program also count some words which is not of our need , i use r.e in it , but its not giving me any appropriate help this is my text file
0 6 9 able#1
0 11 34 unable#1
9 12 22 able#1
0 6 9 able#1-able#1
0 11 34 unable#1*able#1
I dont want my program to count ,-able#1 ,able#1-able#1 ,unable#1*able#1 these type of word , i should only count able#1
0,6,9,able#1(can be done with split, with limit on number of parts), and check the last item to decide to keep the data or not.