[8d2107]: / symptoms_regex_decrypter.py

Download this file

43 lines (32 with data), 967 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
39
40
41
42
import re
def getCleanRegex(regex):
if '.*' in regex:
regex = regex.replace('.*', '[a-z]*')
if '/' in regex:
regex = regex.replace('/', '\/')
return regex
def getName(regex):
if regex[0] != '(':
return regex
else:
output = ''
for c in regex:
if c == '(':
continue
elif c == '|':
return output
else:
output += c
return regex
if __name__ == '__main__':
with open("symptoms_regex_rough.txt") as f:
content = f.readlines()
clean_regexes = {}
for i in range(0, len(content), 2):
line = content[i]
name, regexes = line.split(' - ')
name = name[1:]
for regex in regexes.strip().split(', '):
clean_regexes[getName(regex)] = getCleanRegex(regex)
for name in clean_regexes:
print(name + ': ' + clean_regexes[name])