Simple regex split

Posted by user1383058 on Stack Overflow See other posts from Stack Overflow or by user1383058
Published on 2012-06-15T23:12:52Z Indexed on 2012/06/17 9:16 UTC
Read the original article Hit count: 444

Filed under:

I have the following string:

string = "Peter Pan, Pete Sampras; Little Pete"

And I need to split it up by name:

split_string = ["Peter Pan", "Pete Sampras", "Little Pete"]

I am trying to use re.findall but am having a bit of trouble with it:

print re.findall(r'[,;]', string)
[";", ";", ";"]

What am I doing wrong here and how would I properly use re.findall here or an equivalent to split up the string?

© Stack Overflow or respective owner

Related posts about python