Created
December 4, 2014 09:42
-
-
Save meeuw/2d8cb59499dbbcc5eec8 to your computer and use it in GitHub Desktop.
replace fields in xml file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import fileinput | |
i = 0 | |
output = {} | |
def repl(m): | |
global i | |
global output | |
i += 1 | |
output[i] = m.group(2) | |
return m.group(1)+"%%replace{%i}" % i | |
for line in fileinput.input(): | |
print re.sub(r"(label=\")([^\"]*)", repl, line), | |
for key, value in output.iteritems(): | |
print str(key)+'\t'+value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment