The Python script below demonstrates how to use regex to match on text with a known structure to build a dictionary, then convert the output to JSON data.
The task comes from this StackOverflow question.
Rather than using a procedural approach to handle the lines one at a time and extract the relevant items, I split the text into chunks and then dealt with each using regex pattern to extract the relevant pieces. Expecting questions A and B to always be present and C and D to be there sometimes.
Note use brackets for capture groups.
(.+)
And use of names for capture groups.
(?<option_a>.+)
Read more info on handling Regex groups in Python - Grouping.