Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74339

Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '"("': 0.09; 'literal': 0.09; 'skip:\\ 10': 0.09; 'subject:How': 0.10; 'cc:addr:python- list': 0.11; '")"': 0.16; '-tkc': 0.16; 'although,': 0.16; 'bracket': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'roy': 0.16; 'utterly': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'characters': 0.30; 'comment': 0.34; 'subject:the': 0.34; 'charset:us-ascii': 0.36; 'two': 0.37; 'awesome': 0.38; 'even': 0.60; 'expression': 0.60; 'skip:n 10': 0.64; 'more': 0.64; 'close': 0.67; 'smith': 0.68; 'as:': 0.81; 'received:50.22': 0.84; 'capture': 0.91
Date Thu, 10 Jul 2014 21:37:00 -0500
From Tim Chase <python.list@tim.thechases.com>
To Roy Smith <roy@panix.com>
Subject Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example
In-Reply-To <roy-CC0052.22182710072014@news.panix.com>
References <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> <mailman.11746.1405042179.18130.python-list@python.org> <roy-CC0052.22182710072014@news.panix.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: authenticated_id: tim@thechases.com
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11747.1405046292.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405046292 news.xs4all.nl 2889 [2001:888:2000:d::a6]:39327
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74339

Show key headers only | View raw


On 2014-07-10 22:18, Roy Smith wrote:
> > Outside this are \( and \): these are literal opening and closing
> > bracket characters. So:
> > 
> >    \(\([^)]+\)\)
>
> although, even better would be to use to utterly awesome
>> re.VERBOSE 
> flag, and write it as:
> 
>      \({2} [^)]+ \){2}

Or heck, use a multi-line verbose expression and comment it for
clarity:

  r = re.compile(r"""
    (            # begin a capture group
     \({2}       # two literal "(" characters
     [^)]+       # one or more non-close-paren characters
     \){2}       # two literal ")" characters
    )            # close the capture group
    """, re.VERBOSE)

-tkc


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to decipher :re.split(r"(\(\([^)]+\)\))" in the example fl <rxjwg98@gmail.com> - 2014-07-10 08:37 -0700
  Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Peter Otten <__peter__@web.de> - 2014-07-10 18:49 +0200
  Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example MRAB <python@mrabarnett.plus.com> - 2014-07-10 18:01 +0100
  Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Joel Goldstick <joel.goldstick@gmail.com> - 2014-07-10 13:05 -0400
  Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Albert-Jan Roskam <fomcl@yahoo.com> - 2014-07-10 12:15 -0700
  Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Cameron Simpson <cs@zip.com.au> - 2014-07-11 11:29 +1000
    Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Roy Smith <roy@panix.com> - 2014-07-10 22:18 -0400
      Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Tim Chase <python.list@tim.thechases.com> - 2014-07-10 21:37 -0500
        Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Roy Smith <roy@panix.com> - 2014-07-10 23:33 -0400
          Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Chris Angelico <rosuav@gmail.com> - 2014-07-11 14:31 +1000
          Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example alister <alister.nospam.ware@ntlworld.com> - 2014-07-11 08:00 +0000
          Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Steven D'Aprano <steve@pearwood.info> - 2014-07-11 09:04 +0000
            Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Albert-Jan Roskam <fomcl@yahoo.com> - 2014-07-11 08:18 -0700

csiph-web