MCPcopy Index your code
hub / github.com/python/cpython / search_reverse

Function search_reverse

Lib/idlelib/searchengine.py:189–210  ·  view source on GitHub ↗

Search backwards and return an re match object or None. This is done by searching forwards until there is no match. Prog: compiled re object with a search method returning a match. Chars: line of text, without \\n. Col: stop index for the search; the limit for match.end().

(prog, chars, col)

Source from the content-addressed store, hash-verified

187
188
189def search_reverse(prog, chars, col):
190 '''Search backwards and return an re match object or None.
191
192 This is done by searching forwards until there is no match.
193 Prog: compiled re object with a search method returning a match.
194 Chars: line of text, without \\n.
195 Col: stop index for the search; the limit for match.end().
196 '''
197 m = prog.search(chars)
198 if not m:
199 return None
200 found = None
201 i, j = m.span() # m.start(), m.end() == match slice indexes
202 while i < col and j <= col:
203 found = m
204 if i == j:
205 j = j+1
206 m = prog.search(chars, j)
207 if not m:
208 break
209 i, j = m.span()
210 return found
211
212def get_selection(text):
213 '''Return tuple of 'line.col&#x27; indexes from selection or insert mark.

Callers 1

search_backwardMethod · 0.85

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…