Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; "'',": 0.07; 'string': 0.09; 'provisioning': 0.09; 'cc:addr:python-list': 0.11; "(it's": 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'otherwise:': 0.16; 'rewriting': 0.16; 'subject:String': 0.16; 'worst': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'skip:f 30': 0.19; '>>>': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'case.': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'record': 0.27; "doesn't": 0.30; "i'm": 0.30; 'that.': 0.31; 'beginning': 0.33; 'subject:with': 0.35; 'case,': 0.35; 'are,': 0.36; 'skip:f 40': 0.36; 'charset:us- ascii': 0.36; 'list': 0.37; 'improving': 0.38; 'skip:[ 10': 0.38; 'sure': 0.39; 'catch': 0.60; 'hope': 0.61; 'john': 0.61; 'skip:r 40': 0.68; 'end.': 0.84; 'received:50.22': 0.84; '2013,': 0.91 Date: Wed, 28 Aug 2013 12:32:46 -0500 From: Tim Chase To: random832@fastmail.us Subject: Re: String splitting with exceptions In-Reply-To: <1377710043.22605.15211369.55EB0B33@webmail.messagingengine.com> References: <1377710043.22605.15211369.55EB0B33@webmail.messagingengine.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: none Cc: John Levine , 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377711095 news.xs4all.nl 15971 [2001:888:2000:d::a6]:55542 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53172 On 2013-08-28 13:14, random832@fastmail.us wrote: > On Wed, Aug 28, 2013, at 12:44, John Levine wrote: > > I have a crufty old DNS provisioning system that I'm rewriting > > and I hope improving in python. (It's based on tinydns if you > > know what that is.) > > > > The record formats are, in the worst case, like this: > > > > foo.[DOM]::[IP6::4361:6368:6574]:600:: > > Otherwise: > >>> re.findall('((?:[^[:]|\[[^]]*\])*):?',s) > ['foo.[DOM]', '', '[IP6::4361:6368:6574]', '600', '', ''] > > I'm not sure why _your_ list only has one empty string at the end. I wondered that. I also wondered about bracketed quoting that doesn't start at the beginning of a field: foo.[one:two]::[IP6::1234:5678:9101]:600:: ^ This might be bogus, or one might want to catch this case. -tkc