Returns the capture groups corresponding to the leftmost-first match in text. Capture group 0 always corresponds to the entire match. If no match is found, then None is returned. You should only use captures if you need access to submatches. Otherwise, find is faster
(self, haystack, start=0)
| 153 | |
| 154 | @accepts_bytes |
| 155 | def find_iter(self, haystack, start=0): |
| 156 | """Returns the capture groups corresponding to the leftmost-first match |
| 157 | in text. Capture group 0 always corresponds to the entire match. |
| 158 | If no match is found, then None is returned. |
| 159 | |
| 160 | You should only use captures if you need access to submatches. |
| 161 | Otherwise, find is faster for discovering the location of the overall |
| 162 | match. |
| 163 | """ |
| 164 | hlen = len(haystack) |
| 165 | find_iter = _native.ffi.gc(_native.lib.rure_iter_new(self._ptr), |
| 166 | _native.lib.rure_iter_free) |
| 167 | |
| 168 | match = _native.ffi.new('rure_match *') |
| 169 | while _native.lib.rure_iter_next(find_iter, |
| 170 | haystack, |
| 171 | hlen, |
| 172 | match): |
| 173 | yield RureMatch(match.start, match.end) |
| 174 | |
| 175 | @accepts_bytes |
| 176 | def captures(self, haystack, start=0): |