-2

I want to find all substrings between two commas in a long string.

import re

s = ',0,1,2,3,4,5,6,7,8,9'

re.findall(r',(.*?),', s)

The result is: ['0', '2', '4', '6', '8']. However, I want all the digits from 0 to 9: ['0', '1', '2', '3'...]. What am I doing wrong here?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Alvin
  • 31
  • 4

0 Answers0