Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- before = "2015-08-13"
- after = "2015-08-25"
- full_path = "test.json"
- with open(full_path) as infile:
- data = infile.read()
- data = re.sub(r"(var beforeDate = new Date\().*?(\))", "\\1"+before+"\\2", data)
- data = re.sub(r"(var afterDate = new Date\().*?(\))", "\\1"+after+"\\2", data)
- with open(full_path, "w") as outfile:
- outfile.write(data)
- and the contents of test.json are the following
- \n var beforeDate = new Date('2015-08-21');\n var afterDate = new Date('2015-08-19');\n
- and the output i get is the following
- \n P15-08-13);\n P15-08-25);\n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement