Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!roy From: Roy Smith Newsgroups: comp.lang.python Subject: Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Date: Thu, 10 Jul 2014 22:18:27 -0400 Organization: PANIX Public Access Internet and UNIX, NYC Lines: 21 Message-ID: References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> NNTP-Posting-Host: localhost X-Trace: reader1.panix.com 1405045108 23470 127.0.0.1 (11 Jul 2014 02:18:28 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 11 Jul 2014 02:18:28 +0000 (UTC) User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: csiph.com comp.lang.python:74338 In article , Cameron Simpson 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}