python - Regex, how to get a certain amount of lines of text up to a certain word with regex? -
i trying pull class , class number along prerequisites. having trouble getting course (ex: acct 203), , including prerequisites (ex: acct 301) , nothing else. doing in python, in hopes of later inserting data database. can this? relatively new regex.
acct 203 financial accounting 3 credits development of basic accounting concepts. emphasis on classifying, recording, , reporting of business transactions forms of business organizations. offered every semester. acct 204 managerial accounting 3 credits emphasis on generating, analyzing, , using accounting information in planning , control processes. topics include budgets, standards, cost systems, incremental analysis, , ~nancial statement analysis. offered every semester. prerequisite: acct 203 acct 301 intermediate accounting 3 credits ~rst course in two-course sequence intended provide comprehensive understanding of concepts, principles, assumptions, , conventions used classifying, recording, , reporting economic transactions business entity. offered every fall. prerequisite: acct 204 or permission of instructor acct 302 intermediate accounting ii 3 credits second course in two-course sequence intended provide comprehensive understanding of concepts, principles, assumptions, , conventions used classifying, recording, , reporting economic transactions business entity. offered every spring. prerequisite: acct 301 or permission of instructor acct 303 accounting theory , practice 3 credits course intended provide understanding of items present measurement , reporting problems accountant. discuss current issues accounting profession attempting establish , guidelines measurement , reporting. prerequisite: acct 302 acct 310
i'm not sure whether want or not. that's solution this;
>>> classes = re.findall("[a-z][a-z][a-z][a-z] [0-9][0-9][0-9]", text) >>> in classes: #just find element order ... print(i) ... acct 203 acct 204 acct 203 acct 301 acct 204 acct 302 acct 301 acct 303 acct 302 acct 310
Comments
Post a Comment