Max Erickson
1/25/2008 11:58:00 PM
"Dotan Cohen" <dotancohen@gmail.com> wrote:
> Maybe you mean:
> for match in re.finditer(r'\([A-Z].+[a-z])\', contents):
> Note the last backslash was in the wrong place.
The location of the backslash in the orignal reply is correct, it is
there to escape the closing paren, which is a special character:
>>> import re
>>> s='Abcd\nabc (Ab), (ab)'
>>> re.findall(r'\([A-Z].+[a-z]\)', s)
['(Ab), (ab)']
Putting the backslash at the end of the string like you indicated
results in a syntax error, as it escapes the closing single quote of
the raw string literal:
>>> re.findall(r'\([A-Z].+[a-z])\', s)
SyntaxError: EOL while scanning single-quoted string
>>>
max