Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6857723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:03:48+00:00 2026-05-27T02:03:48+00:00

I’m doing some data analysis over the judge appointment system in France, and using

  • 0

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.

My data, is made of a big list of courts and judges appointments.

Here’s an example list :

Appellate Court of Paris

Blabla about the jugdge : Mr Dominique Martin, blahblahblah Blabla
about the judge : Ms Jeanne Truc

District Court of Paris

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

District Court of Lyon

Blabla about the judge : Ms Lorena Ipsum, blablabh

And there a big lot of these, district and appellate courts mingled. Usually, after a city appellate court, comes the district one.

(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)

And then I need a list of the judges by the courts their in.

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 :

court = re.findall(r'(District Court of.+?|Appelate Court of.+?)\n.+?'+ judge, appointments, re.S)

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.

(I’ve also tried using re.search, but i think re.findall is better for spotting bugs)

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.

(I’m a law student, not a CS one, I beg for forgiveness if I’m doing something utterly wrong there).

Note: The original list i’m parsing : http://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000022472292 (BEWARE that’s an UGLY french government website).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:03:49+00:00Added an answer on May 27, 2026 at 2:03 am

    The problem with your current regex is that even with lazy quantifiers the match will occur as early in the string as the regex allows. For example re.search('A+?B', 'AAB') would match the entire string ‘AAB’, it would not move on to the second ‘A’ so that it matches as few as possible.

    So basically, you get the name of a court and then search through the string until you find the first occurrence of the judge’s name, even if that means you are entering a new court section. Here are two good options for preventing this:

    • First split appointments at each new court, and then search each court for the judge name individually.

    or…

    • Add a negative lookahead to your regex so it will fail if it reaches a new court name before the name of the judge.

    Here is an example with a negative lookahead:

    appointments = """\
    COURT A
    ...
    COURT B
    ...
    COURT C
    Judge Judy"""
    
    >>> re.findall(r'^COURT[^\n]+(?:.(?!^COURT))+Judge Judy', appointments, re.S | re.M)
    ['COURT C\nJudge Judy']
    

    Your current code would be similar to the following:

    >>> re.findall(r'COURT.+?\n.+?Judge Judy', appointments, re.S)
    ['COURT A\n...\nCOURT B\n...\nCOURT C\nJudge Judy']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to construct a data frame in an Rcpp function, but when I
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.