Andrew Freeman wrote:
John Machin wrote:
A couple of points:
(1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
(2) You need to choose your end-anchor correctly; your pattern is
permitting a newline at the end:
I forgot to change search to match. This should be better:
def match(var):
if re.match(r'[LRM]*\Z', var):
return True
else:
return False
I was also thinking if you had a list of these items needing to be
verified you could use this:
>>> l = ['LLMMRR', '00thLL', 'L', '\n']
>>> out = []
>>> map(lambda i: match(i)==False or out.append(i), l)
>>> print out
['LLMMRR', 'L']
--
Andrew
--
http://mail.python.org/mailman/listinfo/python-list