I am trying to split the regex patterns across multiple lines, but it seems to pick up only the pattern specified in the last line. Below example illustrates the problem :
>>> o = re.compile(r'\btext1\b\
... |\btext2\b\
... |\btext3\b')
>>> print o.search(x)
None
>>> x
'text1'
>>> x = 'text3'
>>> print o.search(x)
<_sre.SRE_Match object at 0x025E4CD0>
>>> x = 'text2'
>>> print o.search(x)
None
How can I write this line across multiple lines :
>>> o = re.compile(r'\btext1\b|\btext2\b|\btext3\b')