Can someone help me resolve the following error or point me in the right direction? An incomplete value is returned if ' is in the list value.
Thanks for any help.
def FindName(self,name,list1):
""" searches for a patten in the list, returns the complete list entry. Is case sensitive.
May return incomplete value if ' is in the list value (ie confucius's)"""
if name in list1:
return name
else:
string1 = str(list1).replace('"',"'")
pattern = re.compile("[']"+name+"[^']*")
match = re.search(pattern,string1)
if match:
if match.group().lstrip("'") in list1:
return match.group().lstrip("'")
else:
print 'Fail %s' %match.group().lstrip("'")
return None
else:
return None