Re: s.split() on multiple separators
- From: mrkafk@xxxxxxxxx
- Date: Sun, 30 Sep 2007 12:16:30 -0700
c=' abcde abc cba fdsa bcd '.split()
dels='ce '
for j in dels:
cp=[]
for i in xrange(0,len(c)-1):
The "-1" looks like a bug; remember in Python 'stop' bounds
are exclusive. The indexes of c are simply xrange(len(c)).
Yep. Just found it out, though this seems a bit counterintuitive to
me, even if it makes for more elegant code: I forgot about the high
stop bound.
both here and there.From my POV, if I want sequence from here to there, it should include
I do understand the consequences of making high bound exclusive, which
is more elegant code: xrange(len(c)). But it does seem a bit
illogical...
print re.split('[ce ]', c)
Yes, that does the job. Thanks.
Regards,
Marcin
.
- References:
- s.split() on multiple separators
- From: mrkafk
- Re: s.split() on multiple separators
- From: Bryan Olson
- s.split() on multiple separators
- Prev by Date: Re: s.split() on multiple separators
- Next by Date: Re: Can you please give me some advice?
- Previous by thread: Re: s.split() on multiple separators
- Next by thread: Re: s.split() on multiple separators
- Index(es):