Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #find an replace
  2. import re
  3. FILE_PATH = ""
  4. REGEX = r""
  5. REPLACE =""
  6.  
  7. re_compiled = re.compile(REGEX)
  8. with open(FILE_PATH) as file:
  9. data = file.read()
  10. new_data = re.sub(REGEX,REPLACE, data)
  11. with open(FILE_PATH) as file:
  12. f.write(new_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement