SO I have a text file (alarm.txt) that I convert to a string. The alarm.txt file contains:
Customer Name: LOU
Site: Sao Paulo
Node Name: SPRouter
IP address: 1.2.3.4
I open it using read(). I have experimented with readlines() but that doesn’t seem to work as well:
alarm = open('alarm.txt').read()
So now I am trying to search for “Site:” and copy the text after Site: until the end of the line (in this example i would want to copy “Sao Paulo” into a new string).
I have experimented with re.findall, re.match, re.search.
print re.search(r"Site:*\n", alarm)
I hoped the code above would search for Site: in the string and print the line “Site: Sao Paulo” but it errors. Then copying what comes after Site: into a seperate string, is another story.
I think you need