Python re.findall() returning empty list

I am trying to match some words with the regex and have written a python code for that. The weird thing is re.findall() is returning empty list on matches. However, the pattern and the text file show matches in regxr.com. Here is the code

You are being bitten by backslashes! The backslash is used to as an escape character in Python strings (as in many other languages). For example, \n means "newline" and \r means "carriage return"...and \b means "backspace", aka \x08.

And you have \b in all of your expressions.

So when you write:

>>> pat1 = '...\b...'

You get:

>>> pat1
'...\x08...'

There are two ways to fix this. You can escape each backslash with another backslash, like this:

>>> pat1 = '...\\b...'
>>> pat1
'...\\b...'

And note that you see a \\ there because that is the Python representation of the string; if we were to print out pat1 we get:

>>> print pat1
...\b...

The easier way to fix that is to mark you regular expression strings as "raw strings":

The backslash () character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter r' orR'; such strings are called raw strings and use different rules for backslash escape sequences.