-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrun.py
More file actions
38 lines (29 loc) · 803 Bytes
/
run.py
File metadata and controls
38 lines (29 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import signal
import re
def flag(*args, **kwargs):
print(open("flag").read())
exit()
def main():
print("Welcome to the free online Regular Expression Verifier")
print("Please enter your RegEx and string and I will match them for you\n")
r = input("RegEx: ")
if len(r) > 6:
print("Sorry your regex is too long.")
exit()
s = input("String: ")
if len(s) > 24:
print("Sorry your string is too long.")
exit()
r = re.compile(r)
signal.signal(signal.SIGALRM, flag)
signal.alarm(1)
m = r.search(s)
signal.alarm(0)
if m:
print("Your regex matches the string!")
else:
print("Your regex doesn't match the string!")
if __name__ == "__main__":
signal.alarm(30)
main()