-
Notifications
You must be signed in to change notification settings - Fork 25
/
sample.py
37 lines (26 loc) · 627 Bytes
/
sample.py
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
from regex import Regex
from utils import log
# TRUE
st = 'THISISREGEXTEST'
pattern = '([A-Z]*|[0-9]+)'
# FALSE
st = 'THISISREGEXTEST'
pattern = '([A-Z]+[0-9]+)'
# FALSE
st = '234234abcdefg[*+'
pattern = '([A-Z]+[0-9]*abcdefg)(\[\*\+)'
# TRUE
st = 'AS342abcdefg234aaaaabccccczczxczcasdzxc'
pattern = '([A-Z]+[0-9]*abcdefg)([0-9]*)(\*?|a+)(zx|bc*)([a-z]+|[0-9]*)(asd|fgh)(zxc)'
# NFA
regex = Regex(st, pattern)
result = regex.match()
log(result)
# DFA MINIMIZE
regex = Regex(st, pattern, 2)
result = regex.match()
log(result)
# DFA NO MINIMIZE
regex = Regex(st, pattern, 2, False)
result = regex.match()
log(result)