0

I try to understand the regex in python. How can i split the following sentence with regular expression?

"familyname, Givenname A.15.10"

this is like the phonebook in python regex http://docs.python.org/library/re.html. The person maybe have 2 or more familynames and 2 or more givennames. After the familynames exist ', ' and after givennames exist ''. the last one is the office of the person. What i did until know is

 import re
 file=open('file.txt','r')
 data=file.readlines()
 for i in range(90): 
person=re.split('[,\.]',data[i],maxsplit=2)
print(person)

it gives me a result like this

 ['Wegner', ' Sven Ake G', '15.10\n'] 

i want to have something like

 ['Wegner', ' Sven Ake', 'G', '15', '10']. any idea?
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pyTony
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.