0

I have a string, let's say "MDP-A-17_MDP-A-23.3". I want this string split based on "-", "_" and ".".

The output will be a list:

["MDP", "A", "17", "MDP", "A", "23", "3"]
jamylak
  • 128,818
  • 30
  • 231
  • 230
Aashish P
  • 1,894
  • 5
  • 22
  • 36
  • 1
    excellent question, so +1, but it has been asked a bunch of times already. e.g. http://stackoverflow.com/questions/1059559/python-strings-split-with-multiple-separators – tom10 Jun 13 '13 at 02:58
  • Okay. yeah looks so. I might have missed it. Thanks for pointing to. – Aashish P Jun 13 '13 at 02:59

1 Answers1

6

Pretty sure you can use re.split, as your question suggests...

import re    
s = "MDP-A-17_MDP-A-23.3"
l = re.split(r'[-_.]',s)

Check the docs... http://docs.python.org/2/library/re.html

bozdoz
  • 12,550
  • 7
  • 67
  • 96