Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject: \n ': 0.15; '97m': 0.16; 'collapse': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'list):': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'wrote:': 0.16; 'library': 0.20; '2015': 0.20; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; '(it': 0.29; 'closer': 0.29; 'received:84': 0.32; 'getting': 0.33; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'skip:u 10': 0.61; 'victor': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=OoyysHLt c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=JAI3OqB5mnwA:10 a=IkcTkHD0fZMA:10 a=9UhBjfiFKyHjL8osheQA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 Subject: Re: Split on multiple delimiters, and also treat consecutive delimiters as a single delimiter? To: python-list@python.org References: <55b78aa3$0$2206$65785112@news.neostrada.pl> From: MRAB Date: Tue, 28 Jul 2015 15:30:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438093834 news.xs4all.nl 2894 [2001:888:2000:d::a6]:51241 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94697 On 2015-07-28 15:09, Victor Hooi wrote: > On Tuesday, 28 July 2015 23:59:11 UTC+10, m wrote: >> W dniu 28.07.2015 o 15:55, Victor Hooi pisze: >> > I know the regex library also has a split, unfortunately, that does not collapse consecutive whitespace: >> > >> > In [19]: re.split(' |', f) >> >> Try ' *\|' >> >> p. m. > > Hmm, that seems to be getting closer (it returns a four-element list): > > In [23]: re.split(' *\|', f) > Out[23]: > [' 14 *0 330 *0 760 411', > '0 0 770g 1544g 117g 1414 computedshopcartdb:103.5% 0 30', > '0 0', > '1 19m 97m 1538 ComputedCartRS PRI 09:40:26'] > Try '[ |]+'.