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
  • 120,885
  • 29
  • 225
  • 225
Aashish P
  • 1,772
  • 5
  • 20
  • 35
  • 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
  • 11,847
  • 7
  • 63
  • 92