title: Python regex to extract most recent digit preceding a keyword
body: <p>I have a list of references in text as shown below where the texts in bold is what I want to extract using <code>re.findall()</code>.</p>
  <blockquote>
  <p>'10. T. BESLEY, POLITICAL SELECTION. J. ECON. PERSPECT. 19, 43–60 (2005). 11. J. D. FEARON, CAMBRIDGE STUDIES IN THE THEORY OF DEMOCRACY, IN DEMOCRACY, ACCOUNTABILITY, AND REPRESENTATION, A. PRZEWORSKI, B. MANIN, S. C. STOKES, EDS. (CAMBRIDGE UNIV. PRESS, 1999), PP. 55–97. 12. B. B. DE MESQUITA, A. SMITH, THE DICTATOR’S HANDBOOK: WHY BAD BEHAVIOR IS ALMOST ALWAYS GOOD POLITICS (HACHETTE UK, 2011). 13. S. WONG, S. E. GUGGENHEIM, “COMMUNITY-DRIVEN DEVELOPMENT: MYTHS AND REALITIES” (WPS8435, THE WORLD BANK, 2018), PP. 1–36. 14. A. BEATH, F. CHRISTIA, R. ENIKOLOPOV, DIRECT DEMOCRACY AND RESOURCE ALLOCATION: EXPERIMENTAL EVIDENCE FROM AFGHANISTAN. J. DEV. ECON. 124, 199–213 (2017). 15. B. A. OLKEN, DIRECT DEMOCRACY AND LOCAL PUBLIC GOODS: EVIDENCE FROM A FIELD EXPERIMENT IN INDONESIA. AM. POLIT. SCI. REV. 104, 243–267 (2010). <strong>16. A. BLAKE, M. J. GILLIGAN, INTERNATIONAL INTERVENTIONS TO BUILD SOCIAL CAPITAL: EVIDENCE FROM A FIELD EXPERIMENT IN SUDAN. AM. POLIT. SCI. REV. 109, 427–449 (2015</strong>)'</p>
  </blockquote>
  <p>Essentially, I would like to grab the reference number (here, 16) followed by the citation in interest up to the citation's published year (here, 2015). Because I have the first author's last name in a list, I can use 'BLAKE' as a keyword, but everything else needs to be matched using regex.</p>
  <p>So far I've tried:</p>
  <pre><code>re.findall('\d+?.*?BLAKE.*?\d{4}', refer, re.DOTALL)
  </code></pre>
  <p>But this grabs everything above, since <code>\d+</code> matches '10.', not '16.'. I thought <code>.*?</code> would minimize the string match between the digit and <code>Blake</code>, but it's not. An alternative option is to give a range instead of <code>.*</code>, like <code>re.findall('\d+?{0,5}BLAKE.*?\d{4}', refer, re.DOTALL)</code> but I'm doing this for many other texts and I cannot know in advance how many texts there will be between the reference number and the first author's last name.</p>
  <p>Is there a way to grab the most recent digit (here, 16) preceding a keyword (BLAKE) here? Or a way to minimize the search between digit and a keyword?</p>