Hi, I am quite new to regex. When I saw your question, I wanted to use it as an opportunity to apply the little regex knowledge I have and have been trying to understand the regex used in Q&A since yesterday. I have understood it just enough to provide some pointers for you. I am yet to understand how the negative lookbehind works (which eliminates the ID tag from the answer). But here is something I have tried - please see whether this would help you to move forward.
What I have done is to to add this portion inside the capture group bracket:
.* - match any char 0 or more times
\n* - match any number of new lines
together, they would allow the regex to have some lines, followed by some empty lines, followed by lines, followed by empty lines, etc.
Please check whether this works for you.
I am trying to comment out the Q&A regex - here is what I have now along with some questions I am trying to find answers to. Any help from anyone with experience in regex would be greatly appreciated.
^Q: # Literal
( # Capture Question content
(?:.+\n) # Match one or more characters followed by newline
*) # Match group can occur 0 or more times - so, there can be no content after Question?
\n* # one or more new lines
A: # Literal
( # Capture Answer content
.+ # Same as question - 1+ char
(?:\n # Match new line
(?:^.{1,3}$ | ^.{4} # Match 1 to 4 chars. why?
(?<!<!--) # negative lookbehind. I don't understand it yet
.*) # 0 or more chars
)
*) # capture the pattern 0 or more times
Here is a site which I have found to be very useful
here if you hover over the different parts of the regex, it provides an explanation which I have found to very helpful for me as a beginner.
here is another helpful site - debuggex.com