Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: String splitting with exceptions Date: 28 Aug 2013 18:18:11 GMT Organization: Norwich University Lines: 25 Message-ID: References: <1377710043.22605.15211369.55EB0B33@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net jW7St6BpDliKmstn4nt2+who2dfNBdnP2zkiI1L6rssVvBviAx Cancel-Lock: sha1:MeDRG0LuH8cqteXhQ9dsI5c1hCA= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:53175 On 2013-08-28, Tim Chase wrote: > 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. Good point. My little parser fails on that, too. It'll miss *all* final fields. My parser needs "if s: yield s[b:]" at the end, to operate like str.split, where the empty string is special. -- Neil Cerutti