How to match everything after a double hash "##" until the next double hash "##" and including any repetition of the "#" character which is not "##". For instance the below example should return two matches, one for chapter 1 and 1.1 and the second for chapter 2.
## chapter 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse mollis magna nec felis gravida, id posuere libero molestie.
### subchapter 1.1
Sed vel ipsum eget tortor maximus ultrices vitae eget dolor.
## chapter 2
Aenean pellentesque lectus quis ex tristique ultrices. Vestibulum eget purus eu ipsum vestibulum pulvinar
At the moment the best I found is the following regex:
((?!#){2}[\s\S])+
which however is confused when a ### or #### is found and is counted as a new chapter.
Link to regex example: https://regex101.com/r/gydtq1/1