Target text between a string and convert to a list python

  python, re, regex

I have this long string. I want to target the company data from it. I want to target a block that’s starting with capital letters (which is the company name) and ends on License Type/Action including the text after the :.

DISTRICT ROW LLC

   Premises No.: 0           License Key:   0                                  Date Entered: 09/08/2021

    Tradename: OLSEN RUN WINERY                                               Date Received: 09/03/2021

        Address: 32900 DIAMOND HILL DR, HARRISBURG 97446

  Email Address: [email protected]

License Type/Action: F-COM / N/O





WILCOX PIZZA LLC

   Premises No.: 0           License Key:   0                                  Date Entered: 09/08/2021

    Tradename: FIGARO'S PIZZA                                                 Date Received: 09/02/2021

        Address: 4095 NW LOGAN RD STE B, LINCOLN CITY 97367

  Email Address: [email protected]

License Type/Action:       O / N/O

The output should look like this

['DISTRICT ROW LLC

   Premises No.: 0           License Key:   0                                  Date Entered: 09/08/2021

    Tradename: OLSEN RUN WINERY                                               Date Received: 09/03/2021

        Address: 32900 DIAMOND HILL DR, HARRISBURG 97446

  Email Address: [email protected]

License Type/Action: F-COM / N/O'],





['WILCOX PIZZA LLC

   Premises No.: 0           License Key:   0                                  Date Entered: 09/08/2021

    Tradename: FIGARO'S PIZZA                                                 Date Received: 09/02/2021

        Address: 4095 NW LOGAN RD STE B, LINCOLN CITY 97367

  Email Address: [email protected]

License Type/Action:       O / N/O']

What would be the regular expression for this?

Source: Python Questions

LEAVE A COMMENT