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?

user7294900
  • 52,490
  • 20
  • 92
  • 189
robert
  • 1,723
  • 2
  • 15
  • 25
  • 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