What I want
I'm trying to work out a way in which I can use regex to find two groups in RST news files. I want get change level as well as the change text, for instance a following .rst file:
- hence I want a following regex (changelevel): (change text)
- I was thinking about something like (changelevel): (anything until no next change level)
* Major: This is a **Major** change
* Minnor: This is is a minor change with a typo
* Patch: This
is a multiline
patch
Should return a match, group1 and group2 as following
Match 1:
"* Major: This is a **Major** change"
"* Major: "
"This is a major **Major** change"
Match 2:
"* Patch: This\nis a multiline\n patch"
"* Patch: "
"This\nis a multiline\n patch
What I need help with
I cannot make a regex that will take care of multilines and asterisks present in the "change text" I tried following logic
- Match the change level
^(\*\s+(\w+):\s) - Match anything - with "dot matches newline" option turned on"
.* - Negative forward lookup until I match the change level
(?!^(\*\s+(\w+):\s))
- I ended up with
^(\*\s+(\w+):\s).*(?!^(\*\s+(\w+):\s))but.*seems to just match everything to group 2
What works
I managed to get the first group working with a following regex which works works:
- beginning of the line
- star in front
- then whitespace
- a word
- colon
- white space
^(\*\s+(\w+):\s)

