On Nov 14, 7:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I'm looking for something like: > > multi_split( 'a:=b+c' , [':=','+'] ) > > returning: > ['a', ':=', 'b', '+', 'c'] > > whats the python way to achieve this, preferably without regexp?
pyparsing <http://pyparsing.wikispaces.com/> is quite a cool package for doing this sort of thing. Using your example: #untested from pyparsing import * splitat = Or(":=", "+") lexeme = Word(alphas) grammar = splitat | lexeme grammar.parseString("a:=b+c") #returns (the equivalent of) ['a', ':=', 'b', '+', 'c']. --Sam -- http://mail.python.org/mailman/listinfo/python-list