title: Identifying with regexes and Python the title of a particular paragraph containing an unique word (and French Judges)
body: <p>I'm doing some data analysis over the judge appointment system in France, and using some code to do so. But I've run into a regex problem.</p>
  
  <p>My data, is made of a big list of courts and judges appointments. </p>
  
  <p>Here's an example list :</p>
  
  <blockquote>
    <p>Appellate Court of Paris</p>
    
    <p>Blabla about the jugdge : Mr Dominique Martin, blahblahblah Blabla
    about the judge : Ms Jeanne Truc</p>
    
    <p>District Court of Paris</p>
    
    <p>Blabla about the jugdge : Mr François Dupont, blahblahblah Blabla
    about the jugdge : Mr Jean Dupuis, blahblahblah Blabla about the
    jugdge : Ms Marguerite Lorem, blahblahblah</p>
    
    <p>District Court of Lyon</p>
    
    <p>Blabla about the judge : Ms Lorena Ipsum, blablabh</p>
  </blockquote>
  
  <p>And there a big lot of these, district and appellate courts mingled. Usually, after a city appellate court, comes the district one.</p>
  
  <p>(<em>For the french guys reading this, I'm translating "Tribunal de grande instance" to "District Court" and "Cour d'appel" to "Appellate Court" it's easier to understand if everything is in English</em>)</p>
  
  <p>And then I need a list of the judges by the courts their in.</p>
  
  <p>To achieve that, I started doing a regex using good ol' python 3. First I get a list of all the judges thanks to the Mr and Mrs (well it's french so M. and Mme. ). And then, iterating over each judge in this list to find where the hell their being appointed. I wrote something like that :  </p>
  
  <pre><code>court = re.findall(r'(District Court of.+?|Appelate Court of.+?)\n.+?'+ judge, appointments, re.S)
  </code></pre>
  
  <p>The "judge" var is then the name of the current judge I'm seeking and "appointments" the list I'm regexing on. Dotall flag is on, and if you don't know python, forget about the 'r' before the pattern, it's just about how to interpret special chars in the string following. </p>
  
  <p>(I've also tried using re.search, but i think re.findall is better for spotting bugs)</p>
  
  <p>And the result is always the first one in the list (for instance : Appellate Court of Paris)... just as if it was working as a greedy request, even if I flagged every quatifier with the '?' that in python identifies the quantifier as non-greedy.</p>
  
  <p>(I'm a law student, not a CS one, I beg for forgiveness if I'm doing something utterly wrong there). </p>
  
  <p>Note: The original list i'm parsing : <a href="http://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000022472292" rel="nofollow">http://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000022472292</a> (BEWARE that's an UGLY french government website). </p>