Use this regex:
((.|\n)*?)(a\).*?)\n*?(b\).*?)\n*?(c\).*?)\n*?(d\).*?)\n*?(e\).*?)$|\n*?
It will separate the text into groups where:
- Group 1 - Contains the text before the option
a)
.
- Group 2 - Capture nothing but encapsulate Group 1 capture options.
- Group 3 - Contains the contents of the
a
option until the line break (where option b would start in your example).
- Group 4 - Contains the contents of the
b
option until the line break.
- Group 5 - Contains the contents of the option
c
until the line break.
- Group 6 - Contains the contents of the
d
option until the line break.
- Group 7 - Contains the contents of the
e
option until the line break or end of the text.
You can see the operation of this regex here
Explanation of regex
((.|\n)*?)
- Will capture any character and line break of content until the first delimiter arrives.
(a\).*?)\n*?
- a\)
is equal to a)
and it will be used as a delimiter, so that the first capture group stops capturing on the first occurrence of the a)
sequence, after that the regex will capture all the content until the first line break.
(b\).*?)\n*?
- The operation of this catch group is the same as that of group 3, only capturing from b)
.
(c\).*?)\n*?
- The operation of this catch group is the same as that of group 3, only capturing from c)
.
(d\).*?)\n*?
- The operation of this catch group is the same as that of group 3, only capturing from d)
.
(e\).*?)\$|\n*?
- The operation of this catch group is the same as that of group 3, only capturing from e)
and to the end of the text or a line break, in case you use this regex in a file that has many questions and texts.