how to avoid leading white spaces
Ethan Furman
ethan at stoneleaf.us
Fri Jun 3 18:11:24 EDT 2011
More information about the Python-list mailing list
Fri Jun 3 18:11:24 EDT 2011
- Previous message (by thread): how to avoid leading white spaces
- Next message (by thread): how to avoid leading white spaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chris Torek wrote: >> On 2011-06-03, rurpy at yahoo.com <rurpy at 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~
- Previous message (by thread): how to avoid leading white spaces
- Next message (by thread): how to avoid leading white spaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list