Meine Markierungen bestehen aus einer bestimmten Anzahl, z. ITEM 1 und ITEM2.
Mein regulärer Ausdruck ist
Code: Select all
MDA_regex = 'item[^a-zA-Z\n]*\d\s*\.\s*management\'s discussion and analysis.*?item[^a-zA-Z\n]*\d\s*'
Ich kann 1 und 2 nicht fest codieren, da verschiedene Berichte unterschiedliche Positionen/Header haben können, d. h. Punkt 7 bis Punkt 8 für meinen Wunschtext. Ich verwende Python
Code: Select all
for fileName in os.listdir(path):
fileName = os.path.join(path, fileName)
if os.path.isfile(fileName):
print("opening new file " + fileName)
with open(fileName, 'r', encoding='utf-8', errors='replace') as in_file:
content = in_file.read().replace('\n',' ')
mda_list=re.findall(MDA_regex,content, re.IGNORECASE|re.DOTALL)
print(mda_list)
print(len(mda_list))
Code: Select all
Management's Discussion and Analysis of Financial Condition and
Results of Operations............................................. 22
Item 3.
ITEM 1 . MANAGEMENT'S DISCUSSION AND ANALYSIS OF FINANCIAL CONDITION
AND RESULTS OF OPERATIONS.
FORWARD-LOOKING STATEMENTS
This report contains forward-looking statements. Additional
written or oral forward-looking statements may be made by AMERCO from
time to time in filings with the Securities and Exchange Commission or
otherwise. Management believes such forward-looking statements are
within the meaning of the safe-harbor provisions. Such item 1 statements may
include, but not be limited to, projections of revenues, income or
33
ITEM 2. QUANTITATIVE AND QUALITATIVE DISCLOSURES ABOUT MARKET RISK
DFDFDLF;DF SDLKD dlfldfkdffd;fl;l sdsl; dklkkdsmm,sd item 4
DDFLDFL dlkdsldkf dldfd;lf;f
Kann jemand vorschlagen, wie man damit umgeht? Sollte ich mehrere reguläre Ausdrücke in der if-else-Bedingung verwenden, um jede Bedingung zu überprüfen?
Mobile version