Try to search your question here, if you can't find : Ask Any Question Now ?

What is the regex to match this pattern?

HomeCategory: stackoverflowWhat is the regex to match this pattern?
Avatargaurav asked 4 months ago

I want to match the following text. The pattern is an item starting with a number such as 2.1 on a new line, followed by one or more such items. Some items can spread over multiple lines like 2.1. I want to match a block of such items.

2.1 [ii] Agreement and Plan of Reorganization, by and among the Company,
Force Acq. Corp. and Force Computers, Inc. as amended.
3.1 [viii] Articles of Incorporation of Company, as amended.
3.2 [viii] Bylaws of Company.
10.1 [I] Preferred Stock Purchase Agreement dated September 29, 1983,
together with amendments thereto dated February 28, 1984 and
10.2 [I] Form of Indemnification Agreement between Company and its
officers, directors and certain other key employees.
10.3 [I] Amendment to form of Indemnification Agreement.
10.4 [iv] 1983 Incentive Stock Option Plan, as amended August 13, 1991.
10.5 [vi] 1988 Employee Stock Purchase Plan, as amended October 1992.
10.6 [v] Amended and Restated 1992 Stock Option Plan.

Here is my regex:

pattern = r"(?:nd{1,2}.d{1,2}.{1,200}){2,}n"

text = re.sub(pattern,"", text, re.S)

Not quite there yet. Dotall doesn’t help. Thank you!

1 Answers
Best Answer
AvatarMatthias answered 4 months ago
Your Answer

19 + 15 =

Popular Tags

WP Facebook Auto Publish Powered By :