Returns the start and end byte range of the leftmost-first match in text. If no match exists, then None is returned. Note that this should only be used if you want to discover the position of the match. Testing the existence of a match is faster if you use is_match.
(self, haystack, start=0)
| 134 | |
| 135 | @accepts_bytes |
| 136 | def find(self, haystack, start=0): |
| 137 | """ Returns the start and end byte range of the leftmost-first match |
| 138 | in text. If no match exists, then None is returned. |
| 139 | |
| 140 | Note that this should only be used if you want to discover the position |
| 141 | of the match. Testing the existence of a match is faster if you use |
| 142 | is_match. |
| 143 | """ |
| 144 | match = _native.ffi.new('rure_match *') |
| 145 | if _native.lib.rure_find( |
| 146 | self._ptr, |
| 147 | haystack, |
| 148 | len(haystack), |
| 149 | start, |
| 150 | match |
| 151 | ): |
| 152 | return RureMatch(match.start, match.end) |
| 153 | |
| 154 | @accepts_bytes |
| 155 | def find_iter(self, haystack, start=0): |