# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^((?:outcome|disposition):(?: ?the)? ?judgments? ?of(?: ?the)? ?court ?of ?appeals.*?)(?:(?:\.|;|:|,? ?and|,)?(?: ?the)? judgments? of(?: ?the)?.*(?:trial|circuit|chancery) court)"
test_str = ("DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED. THE JUDGMENT OF THE CHICKASAW COUNTY CIRCUIT COURT IS AFFIRMED IN PART AND REVERSED IN PART AND REMANDED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED. THE JUDGMENT OF THE HINDS COUNTY CIRCUIT COURT IS AFFIRMED IN PART AND REVERSED IN PART, AND THE CASE IS REMANDED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED. THE JUDGMENT OF THE WARREN COUNTY CIRCUIT COURT IS AFFIRMED IN PART, REVERSED IN PART AND THE CASE IS REMANDED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND REVERSED IN PART AND THE JUDGMENT OF THE TRIAL COURT IS REINSTATED AND AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND REVERSED IN PART. THE JUDGMENT OF THE HANCOCK COUNTY CHANCERY COURT IS AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND REVERSED IN PART. THE JUDGMENT OF THE CIRCUIT COURT OF DESOTO COUNTY IS REINSTATED AND AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND REVERSED IN PART. THE JUDGMENTS OF THE CIRCUIT COURT OF CLARKE COUNTY AND THE CIRCUIT COURT OF NEWTON COUNTY ARE AFFIRMED.\n\n"
"DISPOSITION: Court of Appeals judgment reversed. Trial court's judgment affirmed.\n\n"
"OUTCOME: The court reversed the judgment of the intermediate court, and reinstated and affirmed the judgment entered by the trial court. The trial court did not abuse its discretion in refusing to set aside the default judgment.\n\n"
"OUTCOME: The judgment of the court of appeals was reversed and rendered and the judgment of the trial court was reinstated and affirmed.\n\n"
"DISPOSITION: The judgment of the Court of Appeals is affirmed. The judgment of the Warren County Circuit Court is reversed and remanded for further proceedings consistent with this opinion.\n\n"
"DISPOSITION: Court of Appeals judgment reversed. Trial court's judgment affirmed.\n\n"
"DISPOSITION: Judgment of Court of Appeals reversed, and judgment of Circuit Court affirmed.\n\n"
"DISPOSITION: Judgment of Court of Appeals reversed; judgment of Trial Court reinstated and affirmed.\n\n"
"DISPOSITION: JUDGMENT OF THE COURT OF APPEALS AFFIRMED IN PART AND REVERSED IN PART, AND JUDGMENT OF CHANCERY COURT AFFIRMED IN PART AND REVERSED AND REMANDED IN PART.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND REVERSED IN PART. THE JUDGMENT OF THE CIRCUIT COURT OF LOWNDES COUNTY IS AFFIRMED IN PART, VACATED IN PART, AND THE CASE IS REMANDED FOR RESENTENCING.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED IN PART AND VACATED IN PART, AND THE JUDGMENT OF THE CIRCUIT COURT IS AFFIRMED IN PART AND REVERSED AND REMANDED IN PART.\n\n"
"DISPOSITION: COURT OF APPEALS' JUDGMENT AFFIRMED, AND CHANCERY COURT'S JUDGMENT REVERSED AND REMANDED.\n\n"
"DISPOSITION: JUDGMENT OF THE COURT OF APPEALS IS AFFIRMED; JUDGMENT OF THE CIRCUIT COURT OF HINDS COUNTY IS REVERSED AND RENDERED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS AFFIRMED, AND THE JUDGMENT OF THE FORREST COUNTY CIRCUIT COURT REVERSED AND RENDERED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS AS TO HOWARD THOMAS McKINNEY IS REVERSED, AND THE JUDGMENT OF THE WARREN COUNTY CIRCUIT COURT IS AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS REVERSED. THE JUDGMENT OF THE FORREST COUNTY CIRCUIT COURT IS REINSTATED AND AFFIRMED - 01/18/2007. MOTION FOR REHEARING FILED: 02/01/2007. Natchez Elec. & Supply Co. v. Johnson, 2007 Miss. LEXIS 20 (Miss., Jan. 18, 2007).\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS REVERSED. THE JUDGMENT OF THE PIKE COUNTY CIRCUIT COURT IS REINSTATED AND AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS REVERSED, AND THE JUDGMENT OF THE CIRCUIT COURT OF COPIAH COUNTY AFFIRMED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS REVERSED. JUDGMENT OF CHANCERY COURT OF BENTON COUNTY; AFFIRMED IN PART AND REVERSED IN PART.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS REVERSED IN PART. THE JUDGMENT OF THE CHANCERY COURT OF LAFAYETTE COUNTY IS REVERSED IN PART AND THE CASE IS REMANDED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS REVERSED. THE JUDGMENT OF THE CIRCUIT COURT OF HINDS COUNTY IS REVERSED AND RENDERED.\n\n"
"DISPOSITION: THE JUDGMENT OF THE COURT OF APPEALS IS VACATED. THE JUDGMENT OF THE CIRCUIT COURT OF JONES COUNTY IS REVERSED AND THE CASE IS REMANDED.")
matches = re.finditer(regex, test_str, re.MULTILINE | re.IGNORECASE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html