Jussi Piitulainen writes: > Ganesh Pal writes: > > > why is re.search failing in the below case ?? > > Your pattern, '... level-based: [prev 0 , now 1]', matches a literal > string '--- level-based: ' followed by 'p', 'r', 'e', 'v', ' ', '0', > ..., or '1', none of which is the '[' found in your text at that > position. > > Are you sure you need a regexp? > > If you are, make your pattern r'... \[prev 0 , now 1\]'. The 'r' is > not a typo.
On the other hand, the '---' *is* a typo, meant to be an ellipsis where I shortened your text. The shortened pattern would still match it, but that's an accident: '.' has a special meaning in a regexp. Sorry about that. -- https://mail.python.org/mailman/listinfo/python-list