How to decipher :re.split(r"(\(\([^)]+\)\))" in the example
Roy Smith
roy at panix.com
Thu Jul 10 22:18:27 EDT 2014
In article <mailman.11746.1405042179.18130.python-list at python.org>,
Cameron Simpson <cs at zip.com.au> wrote:
> Outside this are \( and \): these are literal opening and closing bracket
> characters. So:
>
> \(\([^)]+\)\)
> Two opening brackets, then at least one character which is not a
> closing bracket, then two closing brackets.
This is a perfectly OK way to write this, but personally I find my eyes
start to glaze over whenever I see things like \(\(, so I would probably
have written it as \({2}. I find that a little easier to read. So, for
the whole thing up to this point:
\({2}[^)]+\){2}
although, even better would be to use to utterly awesome re.VERBOSE
flag, and write it as:
\({2} [^)]+ \){2}
More information about the Python-list
mailing list