Changes regular expression matching headings to allow white space before...

I had white spaces after the heading title and before new line character in my markdown, so the regular expression would not match any heading at all.
I changed the regular expression to allow matching headings with (or without) white space before end of line.
Please review.
Thank you in advance.