Reputation: 45
I have this string:
Overview
Somebody request a review
Title
Test
Test
Resolution
I would like get all the lines after the word "Overview" and before the Word "Resolution"
I tried this Regex: Overview.*[\r\n]+(.*)
https://regex101.com/r/QibhMq/1
Upvotes: 1
Views: 264
Reputation: 3234
It might seem like an overkill, but nested repeating group and the actual boundary words should be pretty robust:
Overview[\r\n]((?:.*[\r\n].*)*)Resolution
Demo in JS:
const data = `Something
Overview
Somebody request a review
Title
Test
Test
Resolution
Blah
Something`
const after = "Overview"
const before = "Resolution"
const regex = new RegExp(`${after}[\r\n]((?:.*[\r\n].*)*)${before}`)
const match = data.match(regex)
if (match) console.log(match[1])
Demo and explanation on Regex101: https://regex101.com/r/QibhMq/6
Upvotes: 2
Reputation: 20014
For this you need to use the modifiers. I would recommend the use of
/s singleline
Overview.*[\r\n]+(.*)/s
Upvotes: 1