-1

I can get split by underscore working, but not with 2 delimiters (in this case underscore and whitespace).

Example:

mystring = Tom Dough__________8.5 7.5 9.5

What i want :

['Tom', 'Dough', '', '', '', '', '', '', '', '', '', '8.5', '7.5', '9.5']

Jérôme Teisseire
  • 1,518
  • 1
  • 16
  • 26
RLmaster
  • 13
  • 2

1 Answers1

1

You want the split function in the re package:

>>> import re
>>> mystring = "Tom Dough__________8.5 7.5 9.5"
>>> re.split(' |_', mystring)
['Tom', 'Dough', '', '', '', '', '', '', '', '', '', '8.5', '7.5', '9.5']
grahamlyons
  • 687
  • 5
  • 15