Last Updated: February 25, 2016
· gnclmorais

Regex to match GitHub’s Markdown code blocks

In a quest to fix a small issue on wtf.js, I struggled on the web for a few hours until I got a regular expression good enough for my purpose: match GitHub’s Markdown code blocks, which means code inside tags like ```.


The expression above is able to do the following (green highlights are matches):

Image courtesy of Refiddle.

2 Responses
Add your response

I think you hit an issue displaying your regex. Coderwall interpreted part of your regex as a code snippet and removed an important piece!

over 1 year ago ·

You are totally right, thank you! I had to change the post a bit, in order to render the regex correctly… Again, thank you!

over 1 year ago ·