From my textbook (automate the boring stuff, Al Sweigart):
"If you want a regular expression that's case-insensitive and includes newlines to match the dot character, you would form your re.compile()
call like this:
someRegexValue = re.compile('foo', re.IGNORECASE | re.DOTALL)
Unfortunately, the re.compile()
function takes only a single value as its second argument. You can get around this limitation by combining the re.IGNORECASE
and re.DOTALL
variables using the pipe character (|
), which in this context is known as the bitwise or operator.
This page is given as additional resource: https://wiki.python.org/moin/BitwiseOperators/
I don't understand why we don't use the bitwise and operator instead. Referring to that page, if we regard x and y as some matching conditions and both must be applied at the same time, I would intuitively use the and operator...
Is there a reason why we can't do that?