I am trying to find a link which contains http or // or \ and surround with a href tag once its found but when reading line by line from the data read from xml..I see the output is split with each letter..please see the input and output below..can anyone suggest where am i going wrong?
INput:-http://pastebin.com/p9H8GQt4
Currentoutput:- http://pastebin.com/7428jK63
sanity_results = sanity_results.replace('\n','<br>\n')
return sanity_results
def main ():
resultslis=[]
xmlfile = open('results.xml','r')
contents = xmlfile.read()
testresults=getsanityresults(contents)
#print testresults
for line in testresults:
#print line
line = line.strip()
#print line
line = re.sub(r'(http://[^\s]+|//[^\s]+|\\\\[^\s]+)', r'<a href="\1">\1</a>', line)
print line
resultslis.append(line)
print resultslis
if __name__ == '__main__':
main()