| 86 | |
| 87 | @accepts_string |
| 88 | def match(self, string, pos=0, endpos=None): |
| 89 | if self._match_rure is None or pos != self._match_rure_pos: |
| 90 | self._match_rure_pos = pos |
| 91 | if pos > 0: |
| 92 | pattern = self.pattern |
| 93 | else: |
| 94 | pattern = br'\A' + self.pattern |
| 95 | self._match_rure = Rure(pattern, |
| 96 | flags=self.rure_flags, |
| 97 | **self.options) |
| 98 | haystack = string[:endpos].encode('utf8') |
| 99 | if self.submatches: |
| 100 | captures = self._match_rure.captures(haystack, pos) |
| 101 | if captures: |
| 102 | return MatchObject(pos, endpos, self, haystack, captures) |
| 103 | else: |
| 104 | match = self._match_rure.find(haystack, pos) |
| 105 | if match: |
| 106 | return MatchObject(pos, endpos, self, haystack, 0) |
| 107 | |
| 108 | @accepts_string |
| 109 | def split(self, string, maxsplit=0): |