acave
asked on
Case insensitive Find
Python is used to parse report text. Text between certain keywords are stored to Db. Like:
value = reportText[(reportText.fin d('FINDING S:'))+9:re portText.f ind('IMPRE SSION:')]
value = value.rstrip()
value = value.lstrip()
Is used to get the text between the FINDINGS: and IMRESSION: and later, store the text in the findings column. I cannot get the other party to protect the report template or send me the data pre-parsed. Often someone will change FINDINGS: to Findings: which breaks the above. I must preserve the case of the reportText.
How can I accomplish the same parsing task but make it so the find is case insensitive?
value = reportText[(reportText.fin
value = value.rstrip()
value = value.lstrip()
Is used to get the text between the FINDINGS: and IMRESSION: and later, store the text in the findings column. I cannot get the other party to protect the report template or send me the data pre-parsed. Often someone will change FINDINGS: to Findings: which breaks the above. I must preserve the case of the reportText.
How can I accomplish the same parsing task but make it so the find is case insensitive?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Correction: use re.search instead of re.match
ASKER
Thanks ramrom, love simplicity. Thanks mish33, got me thinking about encapsulation and reuse. I combined your answers to build a good solution.