0

Here is my idle window right now:

>>> regex = re.compile(r'(\d){3,5}')
>>> regex.findall('234234234')
['3', '4']
>>> regex.findall('234 345 456')
['4', '5', '6']
>>>
>>> regex.search('22343')
<_sre.SRE_Match object; span=(0, 5), match='22343'>
>>> 

Why is it doing this?

JoelG
  • 129
  • 2
  • 4
  • because of capturing group + re.findall. Try this regex with findall `regex = re.compile(r'\d{3,5}')` – Avinash Raj May 09 '16 at 10:55
  • http://stackoverflow.com/questions/31915018/python-re-findall-behaves-weird. `re.findall` returns a list of captured values if capturing groups are defined. A known issue. – Wiktor Stribiżew May 09 '16 at 10:55

0 Answers0