2

I want to parse a string via RegEx (in real world my example is much more complex, else I would use split)

This:

import re 
regex="([a-z])(?:,([a-z]))*$" 
p=re.compile(regex)
print(p.findall("a,b,c,d,e"))

Outputs:

[('a', 'e')]

But I would expect:

['a','b','c','d','e']

As I did group up the [a-z] sequences.

How can I get this desired behaviour?

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
robert
  • 1,921
  • 2
  • 17
  • 27
  • Well, this is so common a question. See the linked question answers. Pay attention to the answer using PyPi `regex` that has the feature support that you need. – Wiktor Stribiżew Sep 18 '17 at 13:00

0 Answers0