Reputation: 21
I am looking to write a reg ex that picks up certain definitions in a contract that are separated by quotation marks. However, some of the definitions contain quotation marks w/in the definition.
I'm unsure how to write a reg ex that will not stop at the first quotation marks, but rather the second instance.
Here is what I have for the following text -- ^\s*\"Consolidated Interest Expense\"([^"]*)
"Consolidated Interest Expense" means, with reference to any period, without duplication, the interest expense (including without limitation interest expense under Capital Lease Obligations that is treated as interest) for such period as is defined in "The Agreement" set forth herein. Consolidated Interest Expense shall be determined for such period on a pro forma basis as if such acquisition or disposition, and any related incurrence or repayment of Indebtedness, had occurred at the beginning of such period.
"Consolidated Net Income" means, with reference to any period, the net income (or loss) of the Company and its Subsidiaries calculated in accordance with GAAP on a consolidated basis (without duplication) for such period• provided that there shall be excluded
I'd love a reg ex that captures the entire "consolidated interest expense" and doesn't stop at "The Agreement" but rather stops at the next definition -- "consolidated net income"
Upvotes: 2
Views: 57
Reputation: 18357
You can use this regex and capture the text till end of paragraph before "Consolidated Net Income"
like you wrote in your post,
^\s*"Consolidated Interest Expense"([\w\W]*\.\R)
Here, this part ^\s*"Consolidated Interest Expense"
you've already written so you know the line can start with optional space followed by literal "Consolidated Interest Expense"
and then ([\w\W]*\.\R)
matches zero or more any character ([\w\W]
is another way to write any character matching even newlines) followed by a literal dot and new line ('\R' matches any newline, windows, linux, Macox)
Let me know if this is indeed what you wanted.
Upvotes: 1