#!/usr/bin/python
import re
ifile = open('copy.txt','r')
ofile = open('third','w')
lines = ifile.readlines()
new_var = ''
for line in lines:
vertex_m = re.search('(vertex\s.*?\sname=)\"([a-z]+)\"',line)
edge_m = re.search('(edge\s.*\s.*\sweight=)(\S*)',line)
if vertex_m:
new_var = vertex_m.group(1) + '"a' + vertex_m.group(2) + '"'
elif edge_m:
new_var = edge_m.group(1) + '1' + edge_m.group(2)
ofile.write(new_var+'\n')
ifile.close()
ofile.close()