Regexp for matching ATX-style headers
%r{ ^(\#{1,6}) # $1 = string of #'s [ ]* (.+?) # $2 = Header text [ ]* \#* # optional closing #'s (not counted) \n+ }x
<code/>
<pre/>
<code/>and<pre/>for code samples.