[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

issue with regular expressions

the following code ends in an exception:

import re
pattern = 'Sottoscrizione unica soluzione'
mylines = []                                # Declare an empty list.
with open ('tmp.txt', 'rt') as myfile:      # Open tmp.txt for reading text.
    for myline in myfile:                   # For each line in the file,
        mylines.append(myline.rstrip('\n')) # strip newline and add to list.
for element in mylines:                     # For each element in the list,
#    print(element)
   match =, element)
   s = match.start()
   e = match.end()

Traceback (most recent call last):
  File "", line 10, in <module>
    s = match.start()
AttributeError: 'NoneType' object has no attribute 'start'

any help? Thanks
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
cell +49 1520 1600 209
cell +39 339 797 0644