fork download
  1. from pyparsing import delimitedList, Literal
  2.  
  3. strs = Literal("x+42") | Literal("100500") | Literal("x++")
  4.  
  5. f = delimitedList(strs, "+")
  6. print(f.parseString("x+42+x+++100500"))
Success #stdin #stdout 0.06s 11056KB
stdin
Standard input is empty
stdout
['x+42', 'x++', '100500']