Issue with regular expressions

cokofreedom at gmail.com cokofreedom at gmail.com
Tue Apr 29 10:44:45 EDT 2008


|                         # ---- Double Quote Text ----
|    "                    # match a double quote
|    (                    #  - Two Possiblities:
|        \\.              # match two backslashes followed by anything
(include newline)
|        |                #         OR
|        [^"]             # do not match a single quote
|    )*                   #  - from zero to many
|    "                    # finally match a double quote
|
|    |                    # ======== OR ========
|
|                         # ---- Single Quote Text ----
|    '                    # match a single quote
|    (                    #  - Two Possiblities:
|        \\.              # match two backslashes followed by anything
(include newline)
|        |                #         OR
|        [^']             # do not match a single quote
|    )*                   #  - from zero to many
|    '                    # finally match a single quote
|    """, DOTALL|VERBOSE)

Used this before (minus those | at the beginning) to find double
quotes and single quotes in a file (there is more to this that looks
for C++ and C style quotes but that isn't needed here), perhaps you
can take it another step to not do changes to these matches?

r""""(\\.|[^"])*"|'(\\.|[^'])*'""", DOTALL)

is it in a single line :)



More information about the Python-list mailing list