Re: s.split() on multiple separators




['ab', 'd', '', 'ab', '', '']

Given your original string, I'm not sure how that would be the
expected result of "split c on the characters in dels".

Oops, the inner loop should be:

for i in xrange(0,len(c)):

Now it works.


>>> c=' abcde abc cba fdsa bcd '
>>> import re
>>> r = re.compile('[ce ]')
>>> r.split(c)
['', 'ab', 'd', '', 'ab', '', '', 'ba', 'fdsa', 'b', 'd', '']

given that a regexp object has a split() method.

That's probably optimum solution. Thanks!

Regards,
Marcin

.



Relevant Pages

  • Re: Generating strings based on pattern
    ... That's an algorithm question, not a C question. ... construct a string which lists each of the ... allowed characters at that position. ... allow the next iteration of the inner loop ...
    (comp.lang.c)
  • Re: [C] [newbie] problem reading from file
    ... check out the isdigit() and isspacelibrary ... > actually I would consider converting all this inner loop to a for-loop ... > space (i.e. less than eight characters have been used) ... (Leor's solution accomplishes this with *np, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Maximum char array size?
    ... > Beginning of inner loop ... Should the ValidSize be less than SearchSize, ... as invalid character, but you can still see characters ...
    (comp.lang.c)
  • Re: FW: The cancer storyline isnt so much the problem...
    ... this storyline in and of itself that's the problem. ... oops, they mixed up the records, you're dying, have a nice day... ... creating interesting characters that interact, ... Along with that, various plot ...
    (rec.arts.comics.strips)
  • Re: Whats a love chair?
    ... characters who say "me, either". ... Oops, wrong newsgroup. ... directions ...
    (uk.legal)