I'm trying to use print function to print results of a re.match but it is coming back as invalid syntax for print
The python version is 2.6.6
import re
def word_replace(text, replace_dict):
rc = re.compile(r"[a-zA-Z]\w*")
def word_replace(text, replace_dict):
word = re.match("(0\w+)\W(0\w+)",lower()
print(word)
return replace_dict.get(word, word)
return rc.sub(translate, text)
old_text = open('1549963864952.xml').read()
replace_dict = {
"value" : 'new_value',
"value1" : 'new_value1',
"value2" : 'new_value2',
"value3" : 'new_value3'
} # {"Word to find" : 'Word to replace'}
output = word_replace(old_text, replace_dict)
f = open("1549963864952.xml", 'w') # File you want to write to
f.write(output) # Write to that file
print(output) # Check that it wrote
Should come back and print results of word = re.match("(0\w+)\W(0\w+)",lower()
but instead i get the below error:
File "location.py", line 8
print(word)
^
SyntaxError: invalid syntax