Skip to content

Instantly share code, notes, and snippets.

@nyanpasu64
Created June 3, 2018 04:42
Show Gist options
  • Select an option

  • Save nyanpasu64/ed0a7d832209d17e48adc5cccc2dedcb to your computer and use it in GitHub Desktop.

Select an option

Save nyanpasu64/ed0a7d832209d17e48adc5cccc2dedcb to your computer and use it in GitHub Desktop.
import re
import sys
def exitPrompt(string="Press enter to exit. . ."):
input(string)
exit()
def error(string, quit=True):
if (quit): exitPrompt("Error: %s" % string)
else: print(string)
def main():
if (len(sys.argv) > 1):
if (len(sys.argv) > 2):
error("Too many arguments.")
filename = sys.argv[1]
else:
filename = str(input("Enter filename: "))
file = open(filename, 'r')
lines = file.readlines()
file.close()
file = open(filename, 'w')
for line in lines:
line = re.sub(r"(?<=\^)[a-g][\+\-]?", '', line, flags=re.IGNORECASE)
file.write(line)
file.close()
print("Done.")
exitPrompt()
if (__name__ == "__main__"):
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment