I have a file named test.txt
I get the file
file=open("test.txt","r")
obj=file.read()
file.close()
print obj
a=a
b=b
c=c
d=e
e=d
e=f
f=e
f=g
g=h
All I want to do with this obj is that, I've to create a regular expression such that,
1.If the left number matches the right number, it should become a single number.ie., a=a should become a.
2.Then d=e & e=d means the same. In this case any one of them must be removed. So as for e=f & f=e.
3. Notice the newlines. Some have \n ,some have \n\n and some have \n\n\n . Make everything into a singe \n for each.
The output should be
a
b
c
d=e
e=f
f=g
g=h
Someone please help me coding the regular expression. I've tried to find one for ages, but I could'nt... Help me please.