I'm the current maintainer of Showdownjs, a markdown parser off which PageDown (stackexchange's markdown parser) is based on. Showdown uses the following regex to parse horizontal rules: /^( ?(-|*|_) ?){3,}[ \t]*$/gm This works fine for most cases. However, the following input: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - abc makes the library painfully slow (takes about 10 seconds on nodeJS and longer in browsers). In fact, if you copy the input above and paste it here on stackexchange, the page will freeze. (stackexchange uses a similar regex to parse `<hr>`) How can I make it faster?