I have the following regex from regex capturing with repeating pattern
([0-9]{1,2}h)[ ]*([0-9]{1,2}min):[ ]*(.*(?:\n(?![0-9]{1,2}h).*)*)
It takes the following string
1h 30min: Title
- Description Line 1
1h 30min: Title
- Description Line 1
- Description Line 2
- Description Line 3
And produces this as a result
Match 1:
"1h 30min: Title
- Description Line 1"
Group 1: "1h"
Group 2: "30min"
Group 3: "Title
- Description Line 1"
Match 2:
"1h 30min: Title
- Description Line 1
- Description Line 2
- Description Line 3"
Group 1: "1h"
Group 2: "30min"
Group 3: "Title
- Description Line 1
- Description Line 2
- Description Line 3"
I now have the matching 1h 30min
not always occur on a new line. So say I hade the following string
1h 30min: Title
- Description Line 1 1h 30min: Title - Description Line 1
- Description Line 2
- Description Line 3
How can I modify the regex to get the following matched result?
Match 1:
"1h 30min: Title
- Description Line 1"
Group 1: "1h"
Group 2: "30min"
Group 3: "Title
- Description Line 1"
Match 2:
"1h 30min: Title - Description Line 1
- Description Line 2
- Description Line 3"
Group 1: "1h"
Group 2: "30min"
Group 3: "Title - Description Line 1
- Description Line 2
- Description Line 3"
I though removing the \n
would do the trick but it just ends up matching everything after the first 1h 30min