프로젝트

일반

사용자정보

개정판 b1f127ba

IDb1f127ba900937ec5c7d8c1a56253e0527c68c9b
상위 385c48f3
하위 480905f9

함의성이(가) 약 5년 전에 추가함

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

클립보드 이미지 추가 (최대 크기: 500 MB)