javascript – regex find block with code in markdown text

I need to identify blocks with code in the markdown text.
The code can be identified using the following template:
“`code“`
******** – 8 characters, each of which can be a space or \r or \n

The first option is easy to find, but the second one is a bit tricky.
First of all, I can’t figure out how to write down that any of the eight characters can be either \s or \r or \n – like [\s\n\r]{8}
Secondly, each line of the code block also contains 8 spaces or \r or \n – so when the code block ends, the normal text will start without spaces – I have no idea how to determine it

Example:

Some text\r\n\r\n    Code\r\n\r\n    code next line\r\n\r\n    another
line\r\n\r\nRegular text again

The result of the regex should be:

\r\n\r\n    Code\r\n\r\n    code next line\r\n\r\n    another line\r\n\r\n

Thanks for your help!

Read more here: Source link