Reputation: 36327
I have the following string:
u'>>\n> yes\n>'
and the following function, to search it for yes or y:
def checkformatch(search_str):
to_find = re.compile(r'\b(yes|y)\b')
match_obj = to_find.search(search_str.lower)
which_word_matched = match_obj.group() if match_obj else ''
return which_word_matched
as far as I can tell nothing is being returned. When I step through this in the pycharm debugger, it doesn't seem to get to the return statement ( very strange behaviour ).
What am I doing wrong?
Upvotes: 0
Views: 44
Reputation: 474161
Your code throws a TypeError: expected string or buffer
on a match_obj = to_find.search(search_str.lower)
line.
lower()
is a method, you need to call it:
to_find.search(search_str.lower())
Upvotes: 3