-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegularExpressionMatching.py
More file actions
49 lines (43 loc) · 926 Bytes
/
RegularExpressionMatching.py
File metadata and controls
49 lines (43 loc) · 926 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
43
44
45
46
47
48
49
s='aa'
p='a.'
l=len(s)
i=0
pl=len(p)
p=list(p)
s=list(s)
if p[-1]=='.':
p[-1]=s[-1]
if s==p:
print (True)
while i<l:
if i<pl:
if p[i]==s[i]:
i+=1
continue
elif p[i]=='.':
if i>0:
if p[i-1] is not '*':
p[i]=s[i]
i+=1
continue
elif:
else:
tmp=i+1
while tmp<l:
if s[tmp].isalpha():
break
tmp+=1
tmp-=1
while tmp>=i:
p[tmp]=s[tmp]
tmp-=1
i-=1
continue
else:
p[i]=s[i]
i+=1
else:
i+=1
else:
break
print (s==p)