Hi guys I want to split the following string that are parsed from a text file using perhaps regular expression in python.
Inside the text file(filename.txt)
iPhone.Case.1.left=1099.0.2
new.phone.newwork=bla.jpg
I want a function that when looping through arrayOfStrings wii split it so that the following is displayed
['iPhone','Case','1','left','1099.0.2']
['new','phone','newwork','bla.jpg']
This is what I have done so far
import re
pattern = '(?<!\d)[\.=]|[\.=](?!\d)'
f = open('filename.txt','rb')
for line in data_file:
str_values = re.split(pattern, line.rstrip())
print str_values
This is what is being printed
['iPhone', 'Case', '1', 'left', '1099.0.2']
['new', 'phone', 'newwork', 'bla', 'jpg']
but I want the last array to be
['new','phone','newwork','bla.jpg']