Possible Duplicate:
Python: Split string with multiple delimiters
Can I do something similar in Python?
Split method in VB.net:
Dim line As String = "Tech ID: xxxxxxxxxx Name: DOE, JOHN Account #: xxxxxxxx"
Dim separators() As String = {"Tech ID:", "Name:", "Account #:"}
Dim result() As String
result = line.Split(separators, StringSplitOptions.RemoveEmptyEntries)
Given a bad data format like this, you could try
re.split():Your job would be much easier if the data was sanely formatted, with quoted strings and comma-separated records. This would admit the use of the
csvmodule for parsing of comma-separated value files.Edit:
You can filter out the blank entries with a list comprehension.