개정판 b1f127ba
issue #49: add regular expression not only allowable but also code
Change-Id: I7278d6a1d14660b0b241d021cd3c7e5826e2e135
DTI_PID/DTI_PID/CodeTables.py | ||
---|---|---|
36 | 36 |
if text.startswidth(value[6]) or tokens: return value[6] |
37 | 37 |
else: |
38 | 38 |
for value in self.values: |
39 |
# code |
|
39 | 40 |
if text.startswith(value[1]): |
40 | 41 |
return value[1], value[1] |
41 | 42 |
else: |
43 |
match = re.search(value[1], text) |
|
44 |
if match and match.start() is 0: |
|
45 |
return text[:match.end()], text[:match.end()] |
|
46 |
|
|
47 |
# allowable |
|
42 | 48 |
matches = [x for x in value[3] if x and text.startswith(x)] |
43 | 49 |
if matches: |
44 | 50 |
return value[1], matches[0] |
... | ... | |
46 | 52 |
if value[3][0]: |
47 | 53 |
match = re.search(value[3][0], text) |
48 | 54 |
if match and match.start() is 0: |
49 |
return value[1], value[1]
|
|
55 |
return value[1], text[:match.end()]
|
|
50 | 56 |
|
51 | 57 |
return None, None |
52 | 58 |
except Exception as ex: |
... | ... | |
63 | 69 |
import re |
64 | 70 |
|
65 | 71 |
for value in self.values: |
72 |
# code |
|
66 | 73 |
if text == value[1]: |
67 | 74 |
return value[1] |
68 | 75 |
else: |
76 |
match = re.search(value[1], text) |
|
77 |
if match and match.start() is 0 and match.end() is len(text): |
|
78 |
return text |
|
79 |
|
|
80 |
# allowable |
|
69 | 81 |
matches = [x for x in value[3] if x and text == x] |
70 | 82 |
if matches: |
71 | 83 |
return value[1] |
내보내기 Unified diff