Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # regex_simplifier.py
- # zzz
- from tkinter import *
- from math import *
- import re
- root = Tk()
- root.title("Regex Simplifier")
- ww = 1280
- hh = 640
- root.geometry(f"{ww}x{hh}+-10+0")
- root.resizable(False, False)
- canvas = Canvas(root)
- canvas.pack()
- options = []
- for i in range(100):
- options.append(IntVar())
- entries = []
- for i in range(100):
- entries.append(StringVar())
- def regex_generator():
- regex_string = ""
- for i in range(len(options)):
- if options[i].get() == 1:
- regex_string += "("
- if i == 0:
- regex_string += "^"
- elif i == 1:
- regex_string += "."
- elif i == 2:
- regex_string += "*"
- elif i == 3:
- regex_string += "+"
- elif i == 4:
- regex_string += "?"
- elif i == 5:
- regex_string += "\\"
- elif i == 6:
- regex_string += "|"
- elif i == 7:
- regex_string += "("
- elif i == 8:
- regex_string += ")"
- elif i == 9:
- regex_string += "["
- elif i == 10:
- regex_string += "]"
- elif i == 11:
- regex_string += "{"
- elif i == 12:
- regex_string += "}"
- elif i == 13:
- regex_string += "\""
- elif i == 14:
- regex_string += "\'"
- elif i == 15:
- regex_string += "\\n"
- elif i == 16:
- regex_string += "\\t"
- elif i == 17:
- regex_string += "\\r"
- elif i == 18:
- regex_string += "\\f"
- elif i == 19:
- regex_string += "\\v"
- elif i == 20:
- regex_string += "\\b"
- elif i == 21:
- regex_string += "\\a"
- elif i == 22:
- regex_string += "\\e"
- elif i == 23:
- regex_string += "\\000"
- elif i == 24:
- regex_string += "\\x00"
- elif i == 25:
- regex_string += "\\u0000"
- elif i == 26:
- regex_string += "\\U00000000"
- regex_string += ")"
- return regex_string
- unwanted = '~`@#%^&*()_+-={}[]|\\:;"\'<,>.?/'
- def regex_text_form():
- scrollbar = Scrollbar(canvas)
- scrollbar.pack(side=RIGHT, fill=Y)
- regex_entry = Text(canvas, yscrollcommand=scrollbar.set, width=158, height=36)
- regex_entry.pack(expand=True, fill='both')
- scrollbar.config(command=regex_entry.yview)
- # button to generate the regex
- btn = Button(canvas, text="Generate", command=lambda: print())
- btn.pack(side=LEFT)
- regex_text_form()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement