Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; '>>>': 0.12; 'wrote:': 0.14; "'',": 0.16; 'element,': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'text:': 0.16; 'there...': 0.16; 'typo': 0.16; 'header:In-Reply-To:1': 0.21; 'subject:how': 0.29; 'rid': 0.29; 'to:addr:python-list': 0.33; 'chris': 0.34; 'header :User-Agent:1': 0.35; 'probably': 0.36; 'think': 0.38; 'subject:: ': 0.38; 'empty': 0.39; 'got': 0.39; 'add': 0.39; 'to:addr:python.org': 0.39; 'email addr:yahoo.com': 0.63; 'received:websitewelcome.com': 0.67; 'dealing': 0.69; 'received:69.56': 0.77; 'received:gateway15.websitewelcome.com': 0.84; 'bar,': 0.91 Date: Fri, 03 Jun 2011 15:11:24 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: how to avoid leading white spaces References: <4de8eef1$0$29996$c3e8da3$5496439d@news.astraweb.com> <1237a287-10b0-4a2d-ba35-97b5238deda1@n11g2000yqf.googlegroups.com> <94svm4Fe7eU1@mid.individual.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:4435 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 21 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307138328 news.xs4all.nl 49183 [::ffff:82.94.164.166]:59658 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6975 Chris Torek wrote: >> On 2011-06-03, rurpy@yahoo.com wrote: > [prefers] >>> re.split ('[ ,]', source) > > This is probably not what you want in dealing with > human-created text: > > >>> re.split('[ ,]', 'foo bar, spam,maps') > ['foo', '', 'bar', '', 'spam', 'maps'] I think you've got a typo in there... this is what I get: --> re.split('[ ,]', 'foo bar, spam,maps') ['foo', 'bar', '', 'spam', 'maps'] I would add a * to get rid of that empty element, myself: --> re.split('[ ,]*', 'foo bar, spam,maps') ['foo', 'bar', 'spam', 'maps'] ~Ethan~